Stop emitting legacy Codex profile config; preserve settings after managed block

Codex 0.144+ refuses to load any config containing the top-level
`profile = "..."` key or `[profiles.<name>]` tables, so every machine running
the kit's output hit "Error loading configuration" and codex would not start.

Profiles now live in per-profile files:
- templates/global/{economy,balanced,deep}.config.toml, installed to
  ~/.codex/<name>.config.toml and selected with `codex --profile <name>`
- config.toml keeps the balanced values as its defaults, so plain `codex`
  behaves as before without a profile selector

`profile` and `profiles.*` stay in the installer's strip lists so upgrading an
existing machine removes the legacy keys from its live config.

Also fixes two latent bugs in the merge, both hit while testing the above:
- Only text *before* the managed block was retained, so anything after it was
  silently deleted on every install. `codex mcp add` appends [mcp_servers.*] to
  the end of config.toml, so those servers would be wiped. Both sides are now
  kept and filtered.
- The config was read with the locale default encoding and a leading BOM was
  preserved, which could strand the BOM mid-file once content was merged around
  the block -- invalid TOML. Read as utf-8-sig, write utf-8.

Verified against a seeded legacy config (BOM at byte 0, machine-specific
[mcp_servers] on both sides of the block): legacy keys stripped, both sides
preserved, idempotent across three runs, and `codex --profile economy exec`
returns a live model response.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-15 21:10:03 +01:00
co-authored by Claude Opus 4.8
parent de379e44ba
commit aedbf8a515
7 changed files with 75 additions and 66 deletions
+5 -1
View File
@@ -92,7 +92,11 @@ Run the audit script periodically. If session storage balloons again, archive th
- `balanced`: everyday profile
- `deep`: higher-effort work when architecture or debugging really needs it
These profiles are defined in `templates/global/config.toml`. The installer preserves machine-specific plugin and trust settings while merging the managed cost and memory block into your live `~/.codex/config.toml`.
Each profile is defined in its own `templates/global/<name>.config.toml` and is installed to `~/.codex/<name>.config.toml`. Select one with `codex --profile <name>`; plain `codex` uses the `config.toml` defaults, which match `balanced`.
Codex 0.144+ rejects the legacy top-level `profile = "..."` key and `[profiles.<name>]` tables, so the kit no longer emits them and strips them from a live config on upgrade.
The installer merges the managed cost and memory block into your live `~/.codex/config.toml`, preserving machine-specific settings that appear *before* the managed block.
## New Machine Rollout