Bug
codex-supermemory install / uninstall can silently overwrite a user’s existing Codex configuration when config parsing fails.
Problem
In src/cli.ts, mergeConfigToml catches TOML parse failures and falls back to an empty object:
try {
existing = TOML.parse(readFileSync(CONFIG_FILE, "utf-8")) as Record<string, unknown>;
} catch {
existing = {};
}
The command then writes the merged config back to ~/.codex/config.toml.
A similar pattern exists for hooks.json, where parsing failures fall back to a default empty hook structure before writing the file again.
This means a user with a pre-existing config file containing a syntax error can lose their existing configuration after running install or uninstall.
Reproduction
- Create a pre-existing Codex config with a TOML syntax error:
# ~/.codex/config.toml
model = "gpt-5"
[features
web_search = true
- Run:
codex-supermemory uninstall
or:
codex-supermemory install
Actual Behavior
The command silently treats the unreadable config as empty and rewrites ~/.codex/config.toml with a minimal/modified configuration.
This can erase unrelated user settings.
Expected Behavior
If an existing config file cannot be parsed, install/uninstall should not overwrite it.
Instead, it should either:
- Abort with a clear parse error and leave the original file untouched, or
- Create a backup before writing a replacement
The safer default is to abort and tell the user which file could not be parsed.
Affected Areas
src/cli.ts
mergeConfigToml
- Hooks config handling around
hooks.json
Suggested Fix
When parsing an existing config file fails:
- Surface a clear error message
- Exit non-zero
- Do not write back to the original file
For example:
Failed to parse ~/.codex/config.toml. Please fix the syntax error before running install/uninstall.
Apply the same behavior to hooks.json parsing failures.
Impact
This is a data-loss risk because install/uninstall may erase unrelated Codex configuration that belongs to the user.
Bug
codex-supermemory install/uninstallcan silently overwrite a user’s existing Codex configuration when config parsing fails.Problem
In
src/cli.ts,mergeConfigTomlcatches TOML parse failures and falls back to an empty object:The command then writes the merged config back to
~/.codex/config.toml.A similar pattern exists for
hooks.json, where parsing failures fall back to a default empty hook structure before writing the file again.This means a user with a pre-existing config file containing a syntax error can lose their existing configuration after running install or uninstall.
Reproduction
or:
Actual Behavior
The command silently treats the unreadable config as empty and rewrites
~/.codex/config.tomlwith a minimal/modified configuration.This can erase unrelated user settings.
Expected Behavior
If an existing config file cannot be parsed, install/uninstall should not overwrite it.
Instead, it should either:
The safer default is to abort and tell the user which file could not be parsed.
Affected Areas
src/cli.tsmergeConfigTomlhooks.jsonSuggested Fix
When parsing an existing config file fails:
For example:
Apply the same behavior to
hooks.jsonparsing failures.Impact
This is a data-loss risk because install/uninstall may erase unrelated Codex configuration that belongs to the user.