main
John Lauer
Add JST GH libraries, native schematic parity and revised sensor harness study with reviewed clips
1ac01c3
"""Show an isolated library-review board for recording, without replacing the project board."""
from pathlib import Path
import json,subprocess,zipfile,base64,shutil
root=Path(__file__).resolve().parents[1];out=root/'checkpoints/sensor-gh-review-v8';remote='C:/Users/john/adom-projects/adom-custom-electronic-load/review/sensor-gh-candidate'
def call(v,a,label):
p=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(a)],capture_output=True,text=True);d=json.loads(p.stdout);(out/(label+'.json')).write_text(json.dumps(d,indent=2)+'\n');assert p.returncode==0 and d.get('success',d.get('ok',True)) and not d.get('errors') and d.get('exitCode',0)==0,d;return d
# Only close the verified task-owned windows; never discard unsaved work.
state=call('kicad_routing_state',{'filePath':'C:/Users/john/adom-projects/adom-custom-electronic-load/review/scaffold-fit-candidate/scaffold-fit-candidate.kicad_pcb'},'previous-live-state')
assert state['revision']=='d8074d493e98b47b81e293506ef557c95f91fce62f17c2f9d120d992d8794fae'
for hwnd in [2500084,1519064]:call('desktop_close_window',{'hwnd':hwnd},f'close-{hwnd}')
script="$p=Get-Process -Id 27916 -ErrorAction SilentlyContinue; if($p){if(-not $p.WaitForExit(10000)){throw 'Task editor still running; inspect save prompt'}}"
call('run_script',{'interpreter':'powershell','scriptB64':base64.b64encode(script.encode()).decode(),'reason':'Wait for only the task-owned editor to exit before opening candidate'},'previous-exit')
# Candidate already contains all selected models.
zpath=out/'viewer-inputs.zip'
with zipfile.ZipFile(zpath,'w',zipfile.ZIP_DEFLATED) as z:
for p in [out/'sensor-gh-candidate.kicad_pcb',out/'sensor-gh-candidate.kicad_pro',out/'sensor-gh-candidate.kicad_dru',out/'fp-lib-table']+list((out/'lib').rglob('*.kicad_mod'))+list((out/'3d').glob('*.step')):z.write(p,p.relative_to(out))
call('send_files',{'filePaths':[str(zpath)],'dest':remote+'/','reason':'Prepare isolated library candidate for requested engineering video'},'viewer-send')
script=f"$ErrorActionPreference='Stop'\nExpand-Archive -LiteralPath '{remote}/viewer-inputs.zip' -DestinationPath '{remote}' -Force\n"
call('run_script',{'interpreter':'powershell','scriptB64':base64.b64encode(script.encode()).decode(),'reason':'Unpack task-owned review assets without changing project board'},'viewer-unpack')
r=call('kicad_open_board',{'filePath':remote+'/sensor-gh-candidate.kicad_pcb','foreground':False},'viewer-open');print(json.dumps({k:v for k,v in r.items() if k!='output'})[:4200])