"""Print only the synthetic CSI fixture from a running app's saved terminal log.
Usage: python3 inspect-history.py COMMIT TERMINAL_HISTORY_LOG
"""
import json,sys
from pathlib import Path
raw=Path(sys.argv[2]).read_bytes()
start=raw.index(b'CSI embedded controls - real PTY / Ghostty')
end=raw.index(b'READY FOR RECONNECT',start)+len(b'READY FOR RECONNECT')
print(json.dumps({'commit':sys.argv[1],'savedHistory':raw[start:end].decode('utf-8')},indent=2))
