#!/usr/bin/env python3
import json, os
from pathlib import Path
cwd=Path.cwd(); state=json.loads((cwd/'phase.json').read_text()); phase=state['phase']
with (cwd.parent/'command-events.jsonl').open('a') as f: f.write(json.dumps({'phase':phase,'cwdIsProject':cwd.name=='workspace','threadIdPresent':bool(os.environ.get('T3CODE_THREAD_ID'))})+'\n')
print(json.dumps({'mcpServers':{'demo':{'type':'http','url':f"http://127.0.0.1:{state['port']}/{phase}",'headers':{'Authorization':'Bearer synthetic-'+phase}}}}))
