#!/usr/bin/python3
import json
import os
from pathlib import Path
import shutil
import sys

with (Path(__file__).parent / 'launches.jsonl').open('a') as log:
    log.write(json.dumps({'args': sys.argv[1:], 'CODEX_HOME': os.environ.get('CODEX_HOME')}) + '\n')
real_codex = shutil.which('codex')
os.execv(real_codex, [real_codex, *sys.argv[1:]])
