"""Run against a fresh, isolated dev home before/after adding Pi through the UI.

Install the published @earendil-works/pi-coding-agent@1.7.0 package and select its
actual dist/bundle/cli.js as Binary path in Add provider (Pi -> Next -> Next).
This script removes unused disabled provider slots, so Pi is the third list row.
No provider responses or versions are simulated.
"""
import json
import pathlib
import sys

home, phase = sys.argv[1:]
path = pathlib.Path(home) / 'userdata' / 'settings.json'
settings = json.loads(path.read_text())
if phase == 'before-add':
    settings['providerInstances']['codex']['config']['binaryPath'] = ''
elif phase == 'after-add':
    settings['providerInstances'] = {
        key: value for key, value in settings['providerInstances'].items()
        if key in ('codex', 'claudeAgent', 'devReplay', 'pi_2')
    }
else:
    raise ValueError('phase must be before-add or after-add')
path.write_text(json.dumps(settings))
