Commit graph

1 commit

Author SHA1 Message Date
Resham Joshi
7b803b293b
fix: survive prototype-named tools and models, never wipe a config on a syntax error, validate plugin names before removal (#1897)
* fix: keep tool and model names like constructor or toString as plain names

Lookups of provider-supplied tool names and model ids into plain-object maps
returned the inherited Object.prototype member, so one session with a tool
named constructor rejected the whole parse, and a model named toString broke
the models report and the menubar payload. Route those lookups through
Object.hasOwn.

* fix: never overwrite an unparseable config.json

readConfig fell back to {} on any error, so one syntax error in a hand-edited
config.json plus any setter (currency, budget, model-alias, ...) saved {} with
one key and erased every other setting. saveConfig now moves an unparseable
file to config.json.corrupt-<timestamp>, says so on stderr and exits 1; read
paths keep the {} fallback with a one-line warning.

* fix: validate the plugin name before plugin remove, info and verify touch disk

plugin remove joined the raw name onto the plugins dir, so
`plugin remove .. --confirm` deleted the whole codeburn config dir. Check the
name against the manifest name pattern first, as the loader already requires.

* fix: keep a model or tool named __proto__ in every running total

The per-model and per-tool totals behind the models report, the menubar
payload, the JSON report and the export assigned into plain objects, so a
name like __proto__ set the prototype instead of adding a row. Build them
prototype-free, and stop the daily cache load from dropping model rows whose
name happens to be an Object.prototype member: they are written own-only.
2026-11-06 09:27:41 +01:00