What: connect's result is taken from the module as JSON text (moejs
AppendJSON keeps JS insertion order) instead of rt.ToGo, which made a Go
map at every level. An object or array connect returns reaches the writer
as a json.RawMessage, so edit.SetJSON writes it in the plugin's order;
strings, numbers, booleans and null are their Go values as before (the
gateway-key mark still matches a string). edit.SetYAML now takes a
json.RawMessage too, as a block-style node in the text's order (it would
have written the bytes as a list of ints), and the env format writes it
compact as before.
Why: Kilo's agent plugin (magpie-community/plugins#90) returns each
model's effort variants weakest first, low, medium, high, the order Kilo
lists them in. Go maps marshal sorted, so Kilo showed high, low, medium.
magpie's own OpenCode wiring already keeps order (openCodeVariants).
The key paths connect returns are still applied in sorted order: each is
a separate edit, and the user's file around them is untouched.
Siblings: rt.ToGo's other caller (middleware's string lists) writes no
file; the Library's MCP block for a plugin agent is built by magpie, not
returned by the plugin.
Run:
- TestPluggedKeepsPluginOrder (Kilo-shaped connect, a kilo.jsonc with a
comment, a theme, $schema, a provider of the user's own with keys
zeta, alpha and a trailing key) and TestPluggedKeepsPluginOrderYAMLAndEnv.
With agentplug.go put back: FAIL, variants written high, low, medium
and provider keys sorted. With yaml.go put back: FAIL, the object
written as a list of byte values. Both pass with the change.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., the three builds: OK.
- go test -tags nogui -timeout 40m ./... under a scratch HOME: all ok.
(A first run with the default 10m timeout timed out in
internal/gateway while four other sessions' suites ran on this box and
the disk was full; the gateway package took 973s under that load and
passed.)
- Real use, sandbox HOME: this build, `magpie plugin add` of
packages/kilo at plugins PR #90 head b67360cb7, a provider whose
fake-chat has efforts stored high, low, medium; `magpie kilo
magpie/fakeup/fake-chat` wrote variants low, medium, high with the
user's comment, $schema, theme and own provider in place, and
@kilocode/cli 7.8.8 `kilo models magpie --verbose` lists them low,
medium, high. `magpie kilo default` put the file back; the only
difference is Kilo's own one-time permission migration.