For an OpenCode 2 magpie wrote OpenCode 1's opencode.json: its provider
under `provider`, the small model as `small_model`, and `reasoning: true`
on models that reason. OpenCode 2 converts the first two in memory, but
it doesn't read `reasoning` and logged a WARN for each such model on
every load ("configuration normalization diagnostic ... omitted
unsupported legacy setting", reproduced with a real OpenCode 2.2.6).
Now the OpenCode that reads the file decides its words (openCodeTwo in
opencode_v2.go: the opencode on PATH, or a WSL distro's probed version,
now asked for opencode too). For 2.x magpie writes `providers.magpie` in
OpenCode 2's shape (openCodeNative), `agents.title.model`, and no
`reasoning`. A file written for OpenCode 1 moves over on the next sync:
openCodeFromV1 ports migrateStandardProvider (v2.2.6) so the user's keys
in magpie's provider (headers, timeout, setCacheKey, their own variants,
limit.output) go along; an empty `provider` is dropped; a small_model
that isn't magpie's stays. OpenCode 1, or an unknown version, gets the
same output as before. OpenChamber writes the same file and takes the
same decision, so the two syncs don't undo each other. mimocode, DevEco
Code and Air keep OpenCode 1's words.
Run:
- gofmt; go vet ./internal/agent for darwin, linux (-tags nogui) and
windows (mote): clean.
- go test -count=1 ./internal/agent on mote: ok, at the rebased head.
- win-run go test -run 'OpenCode|OpenChamber|WSL' ./internal/agent: ok.
- Real binaries on mote, sandbox HOMEs, `opencode debug config
--print-logs`: the file magpie now writes for OpenCode 2 loads in
OpenCode 2.2.6 with no WARN/ERROR, and resolves (model, agents,
providers) exactly as 2.2.6 resolves the OpenCode 1 file it replaces;
the OpenCode 1 file loads in 1.19.5 with no WARN, small_model and
reasoning intact. The old file in 2.2.6 still shows the reasoning WARN.
Broken by hand:
- openCodeTwo always false: TestOpenCode2WritesItsOwnWords,
TestOpenCode2MovesAnOpenCode1File, TestOpenChamberAndOpenCode2AgreeOnWords
and TestOpenCodeTwo red.
- moveProvider not carrying the v1 block over: the move test red on the
user's timeout.
- moveSmall off: the move test red on agents.title.model.
Not tried: a real OpenCode 1 desktop app reading a file written for an
OpenCode 2 CLI on PATH (it would see no magpie provider; 1.19.5 logs
`providers` as not representable); Air's bundled OpenCode version; a real
WSL distro with OpenCode 2.