Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/public/js/project-progress.js # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / public / js / project-progress.js` 183 lines · 19591 bytes Raw Blame History 1 /* AIEN project telemetry. Public data only; credentials stay in CI. */ 2 // A repository link the collector wrote: the forge page of a public repository. 3 // A repository with no public page carries none and is named in plain text. 4 const REPO_URL=/^https:\/\/interplane\.io\/drakestapleton\/(?!\.\.?$)[A-Za-z0-9_.-]+$/; 5 // An event or activity link: a forge page, or "" when the change has no public page (plain text). 6 const SOURCE_URL=/^(?:https:\/\/interplane\.io\/drakestapleton\/[A-Za-z0-9_.\/-]+)?$/; 7 const RID=/^rad:z[1-9A-HJ-NP-Za-km-z]+$/; 8 function renderProgress(data,previousDate){ 9 const root=document.getElementById('aien-growth-observatory'); 10 11 const days=data.series.map(d=>({...d,x:new Date(d.date+'T12:00:00Z'),C:d.langs.C||0,Rust:d.langs.Rust||0,Other:d.loc-(d.langs.C||0)-(d.langs.Rust||0)})); 12 const fmt=new Intl.NumberFormat('en-US'); 13 const short=d3.format('~s'); 14 const dateFmt=d3.utcFormat('%b %-d'); 15 const longDate=d3.utcFormat('%B %-d, %Y'); 16 const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); 17 // A receipt on the forge carries rad: as plain text, so it survives either host. 18 const radText=(url,rid)=>{const m=/\/(?:commit|tree|blob)\/([a-f0-9]{7,40})(?:\/|$)/.exec(url);return m&&RID.test(rid||'')?' '+esc(rid+' '+m[1])+'':'';}; 19 const link=(url,label,cls,rid)=>{const c=cls?' class="'+cls+'"':'';return url?''+label+''+radText(url,rid):''+label+'';}; 20 const color=i=>'var(--viz-series-'+i+')'; 21 const tooltip=root.querySelector('#ag-tooltip'); 22 let selected=previousDate ? days.findIndex(d=>d.date===previousDate) : days.length-1; if(selected<0) selected=days.length-1; 23 const charts=[]; 24 const definitions=[ 25 {id:'ag-code',legend:'ag-code-legend',height:300,unit:'Physical source lines',series:[{key:'loc',label:'All measured source',color:1},{key:'test',label:'Test-path source (included)',color:2}],fill:true}, 26 {id:'ag-revision',legend:'ag-revision-legend',height:240,unit:'Recorded revisions / PRs',series:[{key:'commits',label:'Commits',color:1},{key:'prs',label:'All PRs',color:3},{key:'merged',label:'Merged PRs',color:4}]}, 27 {id:'ag-ci-plot',height:240,unit:'Available workflow runs',series:[{key:'ci',label:'CI runs',color:1}],fill:true}, 28 {id:'ag-tests',height:240,unit:'Distinct named test files',series:[{key:'testfiles',label:'Test files',color:2}],fill:true}, 29 {id:'ag-languages',legend:'ag-lang-legend',height:240,unit:'Physical source lines',series:[{key:'C',label:'C',color:3},{key:'Rust',label:'Rust',color:4},{key:'Other',label:'Other',color:5}],stack:true} 30 ]; 31 const bisect=d3.bisector(d=>d.x).left; 32 function valueAt(key,time){ 33 const i=Math.max(1,Math.min(days.length-1,bisect(days,time))); 34 const a=days[i-1],b=days[i];const t=Math.max(0,Math.min(1,(time-a.x)/(b.x-a.x))); 35 return a[key]+(b[key]-a[key])*t; 36 } 37 function updateSelection(){ 38 const d=days[selected]; 39 root.querySelector('#ag-selected-date').textContent='· '+longDate(d.x); 40 root.querySelector('#ag-lines').textContent=fmt.format(d.loc); 41 root.querySelector('#ag-revisions').textContent=fmt.format(d.commits); 42 root.querySelector('#ag-ci').textContent=fmt.format(d.ci); 43 root.querySelector('#ag-line-context').textContent=fmt.format(d.test)+' in named test files'; 44 root.querySelector('#ag-rev-context').textContent=fmt.format(d.merged)+' merged PRs / '+fmt.format(d.prs)+' total'; 45 root.querySelector('#ag-ci-context').textContent=d.repos+' repositories in retained history'; 46 root.querySelector('#ag-test-summary').textContent=fmt.format(d.testfiles)+' files · '+fmt.format(d.test)+' physical lines'; 47 charts.forEach(c=>{if(c.selection){const line=matchMedia('(prefers-reduced-motion: reduce)').matches?c.selection:c.selection.transition().duration(160);line.attr('x1',c.x(d.x)).attr('x2',c.x(d.x));}}); 48 } 49 function moveTooltip(event,c,time){ 50 const bounds=root.getBoundingClientRect();const px=event.clientX-bounds.left;const py=event.clientY-bounds.top; 51 const active=c.def.series.filter(s=>s.visible!==false); 52 tooltip.innerHTML='
'+longDate(time)+'
'+active.map(s=>'
'+esc(s.label)+''+fmt.format(Math.round(valueAt(s.key,time)))+'
').join('')+'
Between daily snapshots
'; 53 tooltip.style.display='block'; 54 const tw=tooltip.getBoundingClientRect().width; 55 tooltip.style.left=Math.max(0,Math.min(bounds.width-tw,px+16))+'px';tooltip.style.top=Math.max(0,py-88)+'px'; 56 c.hover.attr('x1',c.x(time)).attr('x2',c.x(time)).attr('visibility','visible'); 57 c.markers.attr('visibility',s=>s.visible===false?'hidden':'visible').attr('cx',c.x(time)).attr('cy',s=>{ 58 let v=valueAt(s.key,time);if(c.def.stack){v=0;for(const p of active){v+=valueAt(p.key,time);if(p.key===s.key)break;}}return c.y(v); 59 }); 60 } 61 function draw(c){ 62 const box=c.box;const W=box.clientWidth; if(!W)return; 63 const H=c.def.height;const m={l:70,r:22,t:24,b:48};const a=m.l,b=W-m.r,top=m.t,bottom=H-m.b; 64 const active=c.def.series.filter(s=>s.visible!==false); 65 const x=d3.scaleUtc().domain(d3.extent(days,d=>d.x)).range([a+4,b-4]); 66 const vals=c.def.stack?days.map(d=>active.reduce((s,p)=>s+d[p.key],0)):days.flatMap(d=>active.map(s=>d[s.key])); 67 const extent=d3.extent([0,...vals]);const y=d3.scaleLinear().domain([extent[0],Math.max(1,extent[1])*1.12]).nice().range([bottom-4,top+4]); 68 c.x=x;c.y=y; 69 const svg=d3.select(box).selectAll('svg').data([0]).join('svg').attr('class','ag-chart').attr('viewBox',`0 0 ${W} ${H}`).attr('role','img').attr('aria-label',c.def.unit+' over retained project history'); 70 svg.selectAll('*').remove();svg.append('title').text(c.def.unit+' from '+longDate(days[0].x)+' to '+longDate(days.at(-1).x)); 71 svg.append('desc').text('Daily pinned Git snapshots. The source import on September 19 and subsequent compiler and operating system work account for much of the visible growth.'); 72 svg.append('rect').attr('data-chart-frame','').attr('x',a).attr('y',top).attr('width',Math.max(1,b-a)).attr('height',bottom-top).attr('fill','none').attr('stroke','var(--border)'); 73 const ticks=W<420?3:W<650?4:6; 74 const yg=svg.append('g').attr('transform',`translate(${a},0)`).call(d3.axisLeft(y).ticks(4).tickFormat(short).tickSize(-(b-a))); 75 yg.selectAll('.tick text').attr('dx',-4);yg.selectAll('.tick line').attr('opacity',.45); 76 const xg=svg.append('g').attr('transform',`translate(0,${bottom})`).call(d3.axisBottom(x).ticks(ticks).tickFormat(dateFmt).tickSize(0).tickPadding(10)); 77 xg.selectAll('.tick').each(function(d){const tx=x(d);d3.select(this).select('text').attr('text-anchor',txb-25?'end':'middle');}); 78 svg.append('text').attr('class','axis-title').attr('data-axis','y').attr('x',a).attr('y',13).text(c.def.unit); 79 svg.append('text').attr('class','axis-title').attr('data-axis','x').attr('x',b).attr('y',H-3).attr('text-anchor','end').text('Date · '+days[0].date.slice(0,4)+(days[0].date.slice(0,4)===days.at(-1).date.slice(0,4)?'':'–'+days.at(-1).date.slice(0,4))); 80 const clipId=c.def.id+'-clip';svg.append('defs').append('clipPath').attr('id',clipId).append('rect').attr('x',a).attr('y',top).attr('width',b-a).attr('height',bottom-top); 81 const marks=svg.append('g').attr('clip-path',`url(#${clipId})`); 82 const previous=c.pathPositions||{};const next={}; 83 function paintPath(path,key,high,low){ 84 const shape=lo=>lo?d3.area().x((d,i)=>x(days[i].x)).y0((d,i)=>lo[i]).y1(d=>d):d3.line().x((d,i)=>x(days[i].x)).y(d=>d); 85 const build=(hi,lo)=>shape(lo)(hi);const before=previous[key];next[key]={high,low}; 86 if(before&&c.lastWidth===W&&!matchMedia('(prefers-reduced-motion: reduce)').matches){ 87 const ih=d3.interpolateArray(before.high,high);const il=low?d3.interpolateArray(before.low||before.high,low):null; 88 path.attr('d',build(before.high,before.low)).transition().duration(180).attrTween('d',()=>t=>build(ih(t),il?il(t):null)); 89 }else path.attr('d',build(high,low)); 90 } 91 if(c.def.stack){ 92 const stack=d3.stack().keys(active.map(s=>s.key))(days); 93 stack.forEach(s=>{const path=marks.append('path').attr('class','area').attr('fill',color(active.find(p=>p.key===s.key).color)).attr('opacity',.48);paintPath(path,s.key+'-stack',s.map(d=>y(d[1])),s.map(d=>y(d[0])));}); 94 }else{ 95 active.forEach(s=>{ 96 if(c.def.fill)paintPath(marks.append('path').attr('fill',color(s.color)).attr('opacity',s.key==='test'?.12:.08),s.key+'-area',days.map(d=>y(d[s.key])),days.map(()=>y(0))); 97 paintPath(marks.append('path').attr('fill','none').attr('stroke',color(s.color)).attr('stroke-width',2),s.key+'-line',days.map(d=>y(d[s.key])),null); 98 }); 99 } 100 c.pathPositions=next;c.lastWidth=W; 101 active.forEach(s=>{let v=days.at(-1)[s.key];if(c.def.stack){v=0;for(const p of active){v+=days.at(-1)[p.key];if(p.key===s.key)break;}}marks.append('circle').attr('cx',x(days.at(-1).x)).attr('cy',y(v)).attr('r',3).attr('fill',color(s.color));}); 102 c.selection=marks.append('line').attr('x1',x(days[selected].x)).attr('x2',x(days[selected].x)).attr('y1',top).attr('y2',bottom).attr('stroke','var(--foreground)').attr('stroke-width',1).attr('opacity',.35); 103 c.hover=marks.append('line').attr('data-chart-hover-guide','').attr('y1',top).attr('y2',bottom).attr('stroke','var(--foreground)').attr('stroke-width',1).attr('opacity',.55).attr('visibility','hidden'); 104 c.markers=marks.selectAll('circle.hover').data(c.def.series).join('circle').attr('class','hover').attr('data-chart-hover-marker','').attr('r',4).attr('fill',s=>color(s.color)).attr('visibility','hidden'); 105 svg.append('rect').attr('data-chart-hit','').attr('data-chart-hover-overlay','cross-series').attr('class','cursor-interaction').attr('x',a).attr('y',top).attr('width',b-a).attr('height',bottom-top).attr('fill','transparent').on('pointermove',function(event){const [px]=d3.pointer(event,this);const t=x.invert(Math.max(x.range()[0],Math.min(x.range()[1],px)));moveTooltip(event,c,t);}).on('pointerleave',()=>{if(!c.pinned){tooltip.style.display='none';c.hover.attr('visibility','hidden');c.markers.attr('visibility','hidden');}}).on('click',function(event){c.pinned=!c.pinned;const [px]=d3.pointer(event,this);moveTooltip(event,c,x.invert(Math.max(x.range()[0],Math.min(x.range()[1],px))));}); 106 // Tick labels are measured after every responsive redraw; optional crowded ticks are removed. 107 let lastRight=-Infinity; xg.selectAll('.tick text').each(function(){const r=this.getBoundingClientRect();if(r.leftr.leftt.left-4&&r.topt.top-4))d3.select(this).attr('y',9);}); 110 } 111 definitions.forEach(def=>{ 112 def.series.forEach(s=>s.visible=true);const c={def,box:root.querySelector('#'+def.id),pinned:false};charts.push(c); 113 if(def.legend){const legend=root.querySelector('#'+def.legend);def.series.forEach(s=>{const button=document.createElement('button');button.type='button';button.className='ag-legend cursor-interaction text-small';button.setAttribute('aria-pressed','true');button.innerHTML=''+esc(s.label);button.addEventListener('click',()=>{if(s.visible&&def.series.filter(x=>x.visible).length===1)return;s.visible=!s.visible;button.setAttribute('aria-pressed',String(s.visible));tooltip.style.display='none';draw(c);});legend.append(button);});} 114 c.observer=new ResizeObserver(()=>draw(c));c.observer.observe(c.box);draw(c); 115 }); 116 const slider=root.querySelector('#ag-date-slider');slider.max=days.length-1;slider.value=selected;slider.addEventListener('input',()=>{selected=+slider.value;updateSelection();}); 117 root.querySelector('#ag-events').innerHTML=data.events.map(e=>'
'+esc(e.status)+'
'+esc(e.title)+'

'+esc(e.detail)+'

'+link(e.url,esc(e.repo)+(e.pr?' #'+e.pr:' · first retained commit'),'text-small',e.rid)+'
').join(''); 118 const maxRepo=d3.max(data.repos,r=>(r.size.source||0)+(r.size.test||0)); 119 const repoUrl=r=>REPO_URL.test(r.url||'')?r.url:''; 120 root.querySelector('#ag-repos').innerHTML=data.repos.map(r=>{const total=(r.size.source||0)+(r.size.test||0);return ''+link(repoUrl(r),esc(r.name),'')+'
'+esc(r.archived?'Archived precursor':r.group)+' · '+dateFmt(new Date(r.first+'T12:00:00Z'))+(r.recorded?' · GitHub record to '+dateFmt(new Date(r.recorded+'T12:00:00Z'))+', not read now':'')+'
'+fmt.format(total)+'
'+fmt.format(r.revisions)+''+fmt.format(r.prCount)+''+fmt.format(r.ciCount)+'';}).join(''); 121 root.querySelector('#ag-pins').innerHTML=data.repos.map(r=>'
'+(repoUrl(r)?link(repoUrl(r)+'/tree/'+encodeURIComponent(r.head),esc(r.name),'',r.rid):esc(r.name)+''+esc(String(r.head).slice(0,10))+'')+'
').join(''); 122 root.querySelector('#ag-scope').textContent=dateFmt(days[0].x)+' to '+longDate(days.at(-1).x)+' · '+data.repos.filter(r=>!r.recorded).length+' public repositories'+(data.repos.some(r=>r.recorded)?' and '+data.repos.filter(r=>r.recorded).length+' GitHub-era records':''); 123 root.querySelector('#ag-repo-counts').textContent=data.repos.filter(r=>r.archived).length+' archived · '+data.repos.filter(r=>!r.archived).length+' unarchived'; 124 root.querySelector('#ag-activity').innerHTML=(data.activity||[]).map(p=>'
'+esc(p.repo)+''+esc(p.state)+'
'+link(p.url,esc(p.title),'ag-event-title',p.rid)+'
').join('')||'

Recent activity will appear after the next collection.

'; 125 root.querySelector('#ag-asof').textContent='Measurement cutoff: '+new Intl.DateTimeFormat('en-US',{dateStyle:'long',timeStyle:'short',timeZone:'America/Chicago'}).format(new Date(data.asof))+' America/Chicago. Default branches were read and pinned during collection.'; 126 root.querySelector('#ag-secondary-counts').textContent='Additional footprint: '+fmt.format(data.summary.files)+' distinct source blobs, '+fmt.format(data.summary.docfiles)+' distinct documentation blobs and '+fmt.format(data.summary.docs)+' documentation lines (excluded from source totals). Available CI conclusions at collection: '+fmt.format(data.ciConclusions.success||0)+' success, '+fmt.format(data.ciConclusions.failure||0)+' failure; remaining records were cancelled, skipped or unfinished. These are workflow outcomes, not unique correctness verdicts.'; 127 updateSelection(); 128 129 130 return {destroy(){charts.forEach(c=>c.observer.disconnect());},date(){return selected===days.length-1?null:days[selected].date;}}; 131 } 132 133 (function startProgress(){ 134 const root=document.getElementById('aien-growth-observatory');if(!root)return; 135 let data=null,view,busy=false,error=false; 136 const template=root.innerHTML; 137 function freshness(){ 138 const age=Math.max(0,Date.now()-Date.parse(data.asof)); 139 const stamp=new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',hour:'numeric',minute:'2-digit',timeZoneName:'short',timeZone:'America/Chicago'}).format(new Date(data.asof)); 140 const node=root.querySelector('#ag-freshness');node.dataset.stale=String(age>3*`3600000`||error); 141 node.textContent=(error?'Update check unavailable · ':age>3*`3600000`?'Older snapshot · ':'Collected · ')+stamp; 142 } 143 function display(date){ 144 view?.destroy();root.innerHTML=template;view=renderProgress(data,date);freshness(); 145 root.querySelector('#ag-refresh').addEventListener('click',()=>refresh(true)); 146 } 147 function valid(next){ 148 if(!next||!Array.isArray(next.series)||!next.series.length||!Array.isArray(next.repos)||!next.repos.length||!Number.isFinite(Date.parse(next.asof)))throw Error('Invalid snapshot'); 149 const last=next.series.at(-1); 150 for(const key of ['loc','commits','ci','testfiles'])if(!Number.isSafeInteger(last[key])||last[key]<0||next.summary[key]!==last[key])throw Error('Invalid metric'); 151 for(const p of [...(next.events||[]),...(next.activity||[])])if(typeof p.url!=='string'||!SOURCE_URL.test(p.url)||(p.rid!==undefined&&!RID.test(p.rid)))throw Error('Invalid source URL'); 152 for(const repo of next.repos)if(!/^[.A-Za-z0-9_-]+$/.test(repo.name)||!/^[a-f0-9]{40}$/.test(repo.head)||(repo.url!==undefined&&!REPO_URL.test(repo.url))||(repo.rid!==undefined&&!RID.test(repo.rid)))throw Error('Invalid source pin'); 153 return next; 154 } 155 async function refresh(manual=false){ 156 if(busy)return;busy=true;const button=root.querySelector('#ag-refresh');button.disabled=true;button.textContent='Checking…'; 157 try{ 158 const response=await fetch('/data/project-progress.json?check='+Date.now(),{cache:'no-store',signal:AbortSignal.timeout(20000)}); 159 if(!response.ok)throw Error('Unavailable');const next=valid(await response.json()); 160 if(Date.parse(next.asof)>Date.parse(data.asof)){const date=view.date();data=next;display(date);} 161 error=false;freshness();if(manual)root.querySelector('#ag-refresh').textContent='Up to date'; 162 }catch(e){error=true;freshness();} 163 finally{busy=false;root.querySelector('#ag-refresh').disabled=false;if(!manual||error)root.querySelector('#ag-refresh').textContent='Check for updates';} 164 } 165 async function loadInitial(){ 166 try{ 167 const response=await fetch('/data/project-progress.json',{cache:'default',signal:AbortSignal.timeout(20000)}); 168 if(!response.ok)throw Error('Unavailable'); 169 data=valid(await response.json()); 170 display(); 171 setInterval(()=>{freshness();if(!document.hidden)refresh();},5*60000); 172 document.addEventListener('visibilitychange',()=>{if(!document.hidden)refresh();}); 173 }catch(e){ 174 error=true; 175 const node=root.querySelector('#ag-freshness'); 176 node.dataset.stale='true'; 177 node.textContent='Dataset unavailable · Retry'; 178 const button=root.querySelector('#ag-refresh'); 179 button.addEventListener('click',()=>location.reload()); 180 } 181 } 182 loadInitial(); 183 })();