collision-handling.md 5.9 KB

Install Script Collision Handling - Quick Reference

๐ŸŽฏ What Changed

The install script now detects file collisions before installing and gives you 4 clear options.


๐Ÿ“Š The Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Select Components to Install       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Scan for Existing Files            โ”‚
โ”‚  (Check what would be overwritten)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚ Collisions? โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚                โ”‚
      NO               YES
       โ”‚                โ”‚
       โ–ผ                โ–ผ
   Install      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   Everything   โ”‚ Show Report      โ”‚
                โ”‚ Ask User Choice  โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚               โ”‚               โ”‚              โ”‚
         โ–ผ               โ–ผ               โ–ผ              โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Skip   โ”‚    โ”‚Overwrite โ”‚    โ”‚ Backup & โ”‚   โ”‚ Cancel โ”‚
    โ”‚Existingโ”‚    โ”‚   All    โ”‚    โ”‚Overwrite โ”‚   โ”‚        โ”‚
    โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
        โ”‚              โ”‚               โ”‚             โ”‚
        โ–ผ              โ–ผ               โ–ผ             โ–ผ
    Install      Install All     Backup Files    Exit
    New Only     (Replace)       Then Install

๐ŸŽจ The 4 Options Explained

Option 1: Skip Existing โœ… (SAFEST)

What happens:
  โœ“ New files โ†’ Installed
  โœ“ Existing files โ†’ Untouched
  โœ“ Your changes โ†’ Preserved

Use when:
  โ€ข You've customized files
  โ€ข You only want new components
  โ€ข You're doing incremental updates

Example:
  10 selected, 5 exist
  โ†’ 5 installed, 5 skipped

Option 2: Overwrite All โš ๏ธ (DESTRUCTIVE)

What happens:
  โœ“ New files โ†’ Installed
  โœ“ Existing files โ†’ REPLACED
  โœ— Your changes โ†’ LOST

Use when:
  โ€ข You want latest versions
  โ€ข You haven't customized anything
  โ€ข You want to reset to defaults

Requires: Type 'yes' to confirm

Example:
  10 selected, 5 exist
  โ†’ 10 installed (5 new, 5 replaced)

Option 3: Backup & Overwrite ๐Ÿ”„ (RECOMMENDED)

What happens:
  โœ“ Existing files โ†’ Backed up
  โœ“ New files โ†’ Installed
  โœ“ Existing files โ†’ Replaced
  โœ“ Backup โ†’ Available for restore

Use when:
  โ€ข You want new versions
  โ€ข You want safety net
  โ€ข You're not sure about changes

Backup location:
  .opencode.backup.YYYYMMDD-HHMMSS/

Example:
  10 selected, 5 exist
  โ†’ 5 backed up
  โ†’ 10 installed (5 new, 5 replaced)

Option 4: Cancel โŒ

What happens:
  โ€ข Nothing changes
  โ€ข Exit cleanly

Use when:
  โ€ข You need to review first
  โ€ข You want manual backup
  โ€ข You're not ready

๐Ÿ“‹ Collision Report Example

โš  Found 8 file collision(s):

  Agents (2):
    .opencode/agent/task-manager.md
    .opencode/agent/opencoder.md
    
  Subagents (3):
    .opencode/agent/subagents/reviewer.md
    .opencode/agent/subagents/tester.md
    .opencode/agent/subagents/coder-agent.md
    
  Commands (2):
    .opencode/command/test.md
    .opencode/command/commit.md
    
  Context (1):
    .opencode/context/core/essential-patterns.md

Clear, organized, easy to review!


๐Ÿš€ Quick Decision Guide

Your Situation Best Option Why
First install Any (no collisions) Nothing exists yet
Adding new components Option 1: Skip Keeps your customizations
Want latest versions Option 3: Backup Safe update with rollback
Reset to defaults Option 2: Overwrite Clean slate (careful!)
Not sure Option 4: Cancel Review and decide later

๐Ÿ’ก Pro Tips

Restore from Backup

# List backups
ls -la .opencode.backup.*/

# Restore one file
cp .opencode.backup.20251118-143022/.opencode/agent/my-agent.md .opencode/agent/

# Restore everything
rm -rf .opencode
mv .opencode.backup.20251118-143022/.opencode .opencode

Update One File Only

# Delete the file you want to update
rm .opencode/agent/task-manager.md

# Run installer with "Skip existing"
# Only the deleted file gets reinstalled

See What Changed

# Compare with backup
diff .opencode/agent/my-agent.md .opencode.backup.*/agent/my-agent.md

# Or use git
git diff .opencode/

โœ… Benefits

Before After
โŒ Always overwrites โœ… Asks first
โŒ All-or-nothing โœ… Flexible strategies
โŒ No visibility โœ… Clear collision report
โŒ No backup option โœ… Optional backup
โŒ Risky updates โœ… Safe incremental updates

๐ŸŽฏ Summary

The install script is now smart:

  1. Detects what would be overwritten
  2. Reports collisions clearly
  3. Asks how you want to proceed
  4. Respects your choice
  5. Protects your work

You're in control! ๐ŸŽ‰