app
AI Flow: Reverse Engineering
Public Made by Adomby adom
Photos of a PCB to a tagged KiCad copy: parts placed, copper and nets with their evidence, a schematic, a measured confidence score, bench tests and a video of the run.
main
Caleb
Version 0.3.0: new copper reader, dome via filter, every layer read from the photos, net evidence, measured confidence;…
e874d7d
const p=require(process.env.HOME+'/.cache/hero-studio/node_modules/puppeteer-core');const sleep=ms=>new Promise(r=>setTimeout(r,ms));
(async()=>{const b=await p.launch({headless:'new',executablePath:process.env.HOME+'/.cache/puppeteer/chrome/linux-150.0.7871.24/chrome-linux64/chrome',args:['--no-sandbox','--disable-gpu'],protocolTimeout:900000});
const pg=await b.newPage();await pg.setViewport({width:1920,height:1080,deviceScaleFactor:2});await pg.goto('http://localhost:8893/files/views/123-mimic-pcb.html',{waitUntil:'load',timeout:300000});await sleep(9000);
await pg.evaluate(()=>{[...document.querySelectorAll('button')].find(e=>e.textContent.trim()==='Top')?.click();const re=/Copper · Top|Silk · Top|Mask · Top|Board edge/;document.querySelectorAll('.lyr').forEach(l=>{const c=l.querySelector('input');const w=re.test(l.querySelector('.lyr-name').textContent);if(c.checked!==w)c.click()});window.AdomPcb?.fit?.()});await sleep(2000);
const info=await pg.evaluate(()=>{const all=[...document.querySelectorAll('*')].filter(e=>e.children.length<=2&&e.textContent.trim()==='GND');return all.slice(0,6).map(e=>e.tagName+'.'+e.className+' <'+(e.parentElement?e.parentElement.tagName+'.'+e.parentElement.className:'')+'>')});console.log(info);
for(const n of ['GND','VIN','PHASE_X1','DRV_SDO']){const r=await pg.evaluate(n=>{const c=[...document.querySelectorAll('.panel *, aside *')].filter(e=>e.textContent.trim()===n&&e.children.length===0);const t=c[0];if(!t)return 'missing';(t.closest('[data-net],li,button,.net,.net-row')||t).scrollIntoView({block:'center'});(t.closest('[data-net],li,button,.net,.net-row')||t).click();return (t.closest('[data-net],li,button,.net,.net-row')||t).className},n);await sleep(3000);
const st=await pg.evaluate(()=>document.body.innerText.match(/NET[^\n]*\n?[^\n]*\n?[^\n]*items?/)?.[0]||'');console.log(n,r,st.replace(/\n/g,' '));
await pg.evaluate(()=>{document.querySelectorAll('.panel').forEach(x=>x.style.visibility='hidden')});await sleep(600);await pg.screenshot({path:`cap/n_${n}.png`});await pg.evaluate(()=>{document.querySelectorAll('.panel').forEach(x=>x.style.visibility='')});}
await b.close();console.log('OK')})().catch(e=>{console.error(e);process.exit(1)});