from pathlib import Path
import json,urllib.request
root=Path('/home/lighthouse/esp32-dev/.cache/agent-navigator-0.6b');project=root/'.cache/physical-project';extension=project/'.pi/extensions';extension.mkdir(parents=True,exist_ok=True)
source=(root/'.cache/native-probe/.pi/extensions/native-ui-probe.ts').read_text().replace('navigator_native_ui_probe','ask_watch').replace('Native two choices','Watch: two choices').replace('Native N choices','Watch: three choices').replace('Native free text','Watch: voice answer').replace('Native editor','Watch: second voice answer')
(extension/'watch-native-input.ts').write_text(source)
projects=json.load(urllib.request.urlopen('http://127.0.0.1:18081/api/projects'))
if not any(p['id']=='navigator-acceptance' for p in projects):
 request=urllib.request.Request('http://127.0.0.1:18081/api/projects',data=json.dumps(dict(id='navigator-acceptance',name='Navigator Acceptance',path=str(project))).encode(),headers={'Content-Type':'application/json'},method='POST')
 with urllib.request.urlopen(request) as response:assert response.status==201
print('Registered Navigator Acceptance through Admin API; formal Pi ask_watch fixture ready')
