Skip to content

Conversation

@sisyphus-dev-ai
Copy link
Collaborator

@sisyphus-dev-ai sisyphus-dev-ai commented Jan 7, 2026

Summary

Fixes #556 - bunx opencode install now preserves user configurations instead of overwriting them.

Problem

Previously, the writeOmoConfig function in src/cli/config-manager.ts would:

  1. Read existing user config
  2. Delete the entire agents object from existing config
  3. Merge with new install config
  4. Write result

This caused all user customizations to be lost when reinstalling.

Solution

Removed the delete existing.agents line (line 344) and rely on the existing deepMerge function to properly merge configurations:

  • Existing agent configs are preserved
  • Only fields specified in new install config are updated
  • User customizations survive reinstalls

Changes

  • Removed delete existing.agents from writeOmoConfig function
  • The deepMerge function already handles deep object merging correctly

Testing

  • Type check: ✅ Passed
  • Build: ✅ Successful
  • Existing tests: ✅ All passing

Example

Before (overwrites):

// User's config
{
  "agents": {
    "oracle": { "model": "custom-model", "temperature": 0.5 }
  }
}

// After reinstall - LOST!
{
  "agents": {
    "oracle": { "model": "openai/gpt-5.2" }
  }
}

After (merges):

// User's config
{
  "agents": {
    "oracle": { "model": "custom-model", "temperature": 0.5 }
  }
}

// After reinstall - PRESERVED!
{
  "agents": {
    "oracle": { "model": "openai/gpt-5.2", "temperature": 0.5 }
  }
}

Summary by cubic

Preserves user configurations during reinstall so custom agent settings aren’t lost. bunx opencode install now merges configs instead of overwriting the agents object.

  • Bug Fixes
    • Removed deletion of existing.agents in writeOmoConfig.
    • Rely on deepMerge to update only fields provided by the installer.

Written for commit 7853f1f. Summary will update on new commits.

Previously, the install command would delete the entire 'agents' object
from the user's oh-my-opencode config before merging new install settings.
This caused all user customizations to be lost on reinstall.

Fixed by removing the 'delete existing.agents' line and relying on the
existing deepMerge function to properly merge configs, preserving user
customizations while updating only the fields specified by the installer.

Fixes #556
@greptile-apps
Copy link

greptile-apps bot commented Jan 7, 2026

Greptile Summary

Removed the delete existing.agents statement from writeOmoConfig function that was causing user agent configurations to be lost during reinstall. The existing deepMerge function already handles proper deep merging of objects, so this deletion was unnecessary and destructive.

Changes:

  • Removed delete existing.agents on line 344 of src/cli/config-manager.ts
  • User customizations (like custom temperature, model overrides, etc.) now survive reinstalls
  • The deepMerge function properly merges nested agent objects, updating only specified fields while preserving others

Confidence Score: 5/5

  • This PR is safe to merge - it's a minimal, well-justified bug fix
  • The fix is a simple one-line deletion that removes destructive behavior. The existing deepMerge function (lines 238-263) already handles proper object merging, making the delete existing.agents unnecessary. The change has been tested (type check ✅, build ✅, existing tests ✅) and directly addresses the reported issue [Bug]: Reinstall opencode overwrote my config #556
  • No files require special attention

Important Files Changed

Filename Overview
src/cli/config-manager.ts Removed unnecessary delete existing.agents line, allowing deepMerge to properly preserve user agent configurations during reinstall

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as writeOmoConfig
    participant FS as FileSystem
    participant Merge as deepMerge

    User->>CLI: bunx opencode install
    CLI->>CLI: generateOmoConfig(installConfig)
    Note over CLI: Creates newConfig with default agent models
    
    CLI->>FS: Check if oh-my-opencode.json exists
    alt Config file exists
        FS-->>CLI: File exists
        CLI->>FS: readFileSync(omoConfigPath)
        FS-->>CLI: existing config content
        CLI->>CLI: parseJsonc(content)
        Note over CLI: Parse existing user config
        
        Note over CLI: ❌ OLD: delete existing.agents<br/>✅ NEW: Skip delete
        
        CLI->>Merge: deepMerge(existing, newConfig)
        Note over Merge: Recursively merge objects<br/>Override model fields<br/>Preserve custom fields (e.g. temperature)
        Merge-->>CLI: merged config
        
        CLI->>FS: writeFileSync(merged)
        Note over FS: User's custom agent config preserved!
    else Config file doesn't exist
        CLI->>FS: writeFileSync(newConfig)
        Note over FS: Fresh installation
    end
    
    CLI-->>User: success: true
Loading

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Reinstall opencode overwrote my config

2 participants