Skip to content

install: config bridges truncate a user's existing ~/.codex/config.toml / ~/.hermes/config.yaml / .aider.conf.yml #149

Closed

Description

@56phil

Summary

Two config-bridge functions in the installer replace a pre-existing user config file in full, with no backup and no prompt. The guard only checks whether the file contains one specific key line; if the file exists but lacks that key, it is overwritten completely.

Where

1. scripts/lib/context-wire.sh:37

wire_config_bridge() {
  local bridge_file="$1"
  local bridge_key="$2"
  local agents_path="${3:-AGENTS.md}"

  mkdir -p "$(dirname "$bridge_file")"
  if [[ -f "$bridge_file" ]] && grep -q "^${bridge_key}:" "$bridge_file" 2>/dev/null; then
    return 0
  fi
  printf '%s: %s\n' "$bridge_key" "$agents_path" > "$bridge_file"
}

2. scripts/lib/install-helpers.js:92-99 (same defect, second copy)

function bridgeHermesConfig(configPath) {
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
  if (fs.existsSync(configPath)) {
    const existing = fs.readFileSync(configPath, 'utf8');
    if (/^instructions:/m.test(existing)) return;
  }
  fs.writeFileSync(configPath, 'instructions: AGENTS.md\n');
}

Called unconditionally for ~/.hermes/config.yaml at install-helpers.js:171 and :371, and for the Codex / aider bridges via wire_config_bridge.

Impact

A user who already has ~/.codex/config.toml (e.g. model = "o3", [projects] tables), ~/.hermes/config.yaml, or .aider.conf.yml that does not contain the one key the guard tests for will have that file replaced by a single line, silently, with no backup.

This contradicts the invariant stated a few lines earlier in the same file (install-helpers.js:26):

Refuse to replace a destination that is not already a bigpowers-managed

That guard (assertReplaceable) covers managed files/dirs but does not cover these config bridges.

Repro

  1. mkdir -p ~/.codex && printf 'model = "o3"\n[projects.x]\ntrust_level = "trusted"\n' > ~/.codex/config.toml
  2. Run the installer
  3. cat ~/.codex/config.toml — the file is now the single bridge line; the previous contents are gone

Expected

Merge the key into the existing document, or refuse and print the snippet for the user to paste. Never > / writeFileSync a non-empty config file.

Suggested fix

  • context-wire.sh: append only when the file is empty; otherwise write the line to stderr and return non-zero, or do a real merge.
  • install-helpers.js: parse first (yaml/toml), set the key on the parsed object, write back only on success; refuse and warn otherwise.
  • Both copies need the fix — a fix applied to one leaves the other.

Environment

  • bigpowers 2.88.9 (npm); also present on upstream main as of this report
  • macOS arm64, Node 22, bash 3.2

Activity

  1. danielvm-git commented on Oct 25, 2026

    @danielvm-git
    Owner

    @56phil — Catching a destructive write that contradicts the codebase's own assertReplaceable invariant is exactly the kind of review that protects real users' data. Your reproduction steps were clean and your Expected/Actual section made the fix path obvious. Thank you for protecting other users' configurations — this one mattered.

  2. github-actions commented on Oct 25, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.88.12 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. added a commit that references this issue on Oct 28, 2026
    120a0d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions