Files
magpie/internal/cli
yetone 0c4e3455ee agents: a line magpie writes into a TOML, YAML or env config has a note above it saying so
Jevik_AI on X deleted magpie's folders by hand. Codex's config.toml kept
openai_base_url = "http://127.0.0.1:3425/backend-api/codex", with nothing
in the file naming magpie, and every Codex turn failed with a 502.

Each line magpie writes that points at the gateway, or at magpie's model
list, now gets a comment line of its own just above it:

  # magpie: Codex on magpie's local gateway; Disconnect in magpie or
  #   `magpie uninstall` undoes it, or delete this line and the model line
  model_provider = "magpie"

- Only a line the write adds or changes, or one that had a note, gets one.
  A line of the user's own that magpie leaves alone gets none.
- The note is never on the value's line. Grok App's providers.rs reads the
  rest of a line as the value, and an end-of-line comment broke
  TestGrokApp in a first try.
- Every write takes the notes out and puts back the ones still needed, so
  a note goes with its line and Disconnect leaves none.
- No note in JSON. A YAML note that would change what the file reads as
  isn't added.
- Wired in run (agent.MarkWritten); tests leave edit.Mark nil so their
  exact bytes stay.

Run at this commit's tree (worktree, sandbox HOME, private GOCACHE):
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui ok.
- go test -tags nogui -run Mark ./internal/edit ./internal/agent: ok.
- ./internal/agent and ./internal/edit whole with edit.Mark forced on for
  every test (a snapshot with lineNote set in agent's TestMain): edit ok;
  agent fails only TestDshRouteKeepsTheAPIPickedInDsh and
  TestDshSearchThroughGateway, which compare exact bytes and see the note
  line. With Mark unset (as shipped) they pass.
- Real Codex: built magpie from this tree, `magpie codex fakeai/fake-1` in
  a sandbox HOME. config.toml got the three notes above model_provider,
  model_catalog_json and openai_base_url; `codex mcp list` and `codex
  features list` (codex-cli 0.162.1) read it, rc 0, and Python's tomllib
  reads the same values. `magpie codex default` took them out.
- Broken by hand: a note on every line, not only changed ones ->
  TestMarkTOML and TestMarkOnlyWhatMagpieWrites red.

- The notes' line filter is withoutNotes, unexported: an exported
  Unmarked put a word the routing plugin translates into a Go file, and
  i18n-keys' "a plugin's words are its own" went red on it. It passes
  now.

Full suite: run with the uninstall commit that follows, recorded there.
2026-10-29 17:42:35 +08:00
..