AfterConfig Adds TOML Overlays That Keep Every Comment
Aftermarket 0.7.0 teaches AfterConfig to read and write TOML. That’s the config format of a lot of newer software: Rust and Python tools, Go services, Hugo, plenty of daemons. Their vendors replace config.toml on every upgrade, same as everyone else.
An overlay works the same way it does for JSON, YAML and .env. You list your changes by dot path, each one guarded by the value it expects, and config apply writes the result to a separate file. The vendor’s file is never touched.
Your lines, not a reformatted file
The part that took the work: the output looks like the vendor’s file. A TOML config is usually full of comments explaining each setting, and a tool that parses the file and writes it back out loses all of them.
AfterConfig doesn’t write the file back out. It edits the lines. A changed value is replaced where it stands, so this line from the example:
timeout = 30 # seconds
comes out as:
timeout = 120 # seconds
Every line the overlay doesn’t name stays byte for byte. That includes comments, blank lines, Windows line endings and even a missing newline at the end of the file. A new key goes at the end of the table it belongs to. A renamed key keeps its line, and a renamed table only gets new headers.
Types stay put
TOML has dates, times, integers and floats as separate types, and some programs care. So a date set from text in the same shape stays a date. A float set to 45 is written 45.0. A value that’s already right is left alone, spelling and all, so a port written as 0x1F90 stays hex.
The result is read back before it’s written, and for TOML that check includes types. config test compares the same way, so a fixture expecting "2026-10-21" as text won’t pass against a date.
When a change can’t be made on the lines, such as turning a whole table into a single value, the file is written again from its values. It still holds exactly what was meant, but the comments don’t survive that.
Try it
The download archive has examples/vendor-app-toml, the same vendor upgrade as the JSON example, written in TOML:
aftermarket config apply --overlay examples/vendor-app-toml/overlay.yaml --out config.toml
diff examples/vendor-app-toml/1.0/config.toml config.toml
Seven lines differ, and nothing else. Point it at the vendor’s 1.1 file with --base and apply stops at the two lines where the vendor changed a default itself.
AfterHook reads TOML now too, so a .toml file it watches reports changes field by field. The full format is in the AfterConfig reference, and the files are on the download page.