"""Redact local workspace paths; retain conversation output and Read tool label."""
import sys, subprocess
from pathlib import Path
from PIL import Image, ImageDraw
root,out=map(Path,sys.argv[1:3])
for side in ['base','head']:
    source=next((root/side).rglob('001-parent-thinking.png'))
    Image.open(source).save(out/f'{side}-parent.png')
    source=next((root/side).rglob('002-child-reply.png'))
    im=Image.open(source);d=ImageDraw.Draw(im)
    for box in [(675,109,934,131),(374,199,932,221)]:
        d.rectangle(box,fill='#e6e6e6');d.text((box[0]+5,box[1]+5),'[local path redacted]',fill='#555555')
    im.save(out/f'{side}-child.png')
    video=next((root/side).rglob('video.webm'))
    start,end=(19,34) if side=='base' else (18,24.8)
    filters="drawbox=x=675:y=109:w=259:h=22:color=gray:t=fill:enable='gte(t,22)',drawbox=x=374:y=199:w=558:h=22:color=gray:t=fill:enable='gte(t,22)'"
    filters+=f",trim=start={start}:end={end},setpts=PTS-STARTPTS,tpad=stop_mode=clone:stop_duration=3"
    subprocess.run(['ffmpeg','-y','-i',str(video),'-vf',filters,'-an','-c:v','libx264','-crf','20','-pix_fmt','yuv420p','-movflags','+faststart',str(out/f'{side}-navigation.mp4')],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
