The install script now intelligently detects and handles file collisions when installing OpenCode components into an existing .opencode/ directory.
Before installing any files, the script:
.opencode/ directoryWhen collisions are detected, you get 4 options:
✅ Only install new files
✅ Keep ALL existing files unchanged
✅ Your customizations are preserved
✅ Safe for incremental updates
Use when:
Example:
Selected: 10 components
Existing: 5 files
Result: 5 new files installed, 5 existing files untouched
⚠️ Replace ALL existing files with new versions
⚠️ Your customizations will be LOST
⚠️ Requires confirmation (type 'yes')
Use when:
Example:
Selected: 10 components
Existing: 5 files
Result: All 10 files installed (5 overwritten, 5 new)
✅ Backs up existing files to .opencode.backup.{timestamp}/
✅ Then installs new versions
✅ You can restore from backup if needed
✅ Best of both worlds
Use when:
Example:
Selected: 10 components
Existing: 5 files
Result:
- 5 files backed up to .opencode.backup.20251118-143022/
- All 10 files installed (5 updated, 5 new)
Restore from backup:
# View backup
ls -la .opencode.backup.*/
# Restore specific file
cp .opencode.backup.20251118-143022/.opencode/agent/my-agent.md .opencode/agent/
# Restore all
rm -rf .opencode
mv .opencode.backup.20251118-143022/.opencode .opencode
❌ Exit without making any changes
Use when:
$ bash <(curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh) --developer
╔════════════════════════════════════════════════════════════════╗
║ ║
║ OpenCode Agents Installer v1.0.0 ║
║ ║
╚════════════════════════════════════════════════════════════════╝
▶ Checking dependencies...
✓ All dependencies found
▶ Fetching component registry...
✓ Registry fetched successfully
▶ Installation Preview
Profile: developer
Components to install (22 total):
Agents (4): task-manager codebase-agent image-specialist workflow-orchestrator
Subagents (6): reviewer tester documentation coder-agent build-agent codebase-pattern-analyst
Commands (6): test commit context clean optimize prompt-enhancer
Tools (2): env gemini
Contexts (2): essential-patterns project-context
Config (2): env-example readme
Proceed with installation? [Y/n]: y
▶ Preparing installation...
▶ Checking for file collisions...
⚠ Found 8 file collision(s):
Agents (2):
.opencode/agent/task-manager.md
.opencode/agent/codebase-agent.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
How would you like to proceed?
1) Skip existing - Only install new files, keep all existing files unchanged
2) Overwrite all - Replace existing files with new versions (your changes will be lost)
3) Backup & overwrite - Backup existing files, then install new versions
4) Cancel - Exit without making changes
Enter your choice [1-4]: 1
▶ Installing components...
✓ Installed agent: image-specialist
✓ Installed agent: workflow-orchestrator
ℹ Skipped existing: agent:task-manager
ℹ Skipped existing: agent:codebase-agent
ℹ Skipped existing: subagent:reviewer
ℹ Skipped existing: subagent:tester
✓ Installed subagent: documentation
ℹ Skipped existing: subagent:coder-agent
✓ Installed subagent: build-agent
✓ Installed subagent: codebase-pattern-analyst
ℹ Skipped existing: command:test
ℹ Skipped existing: command:commit
✓ Installed command: context
✓ Installed command: clean
✓ Installed command: optimize
✓ Installed command: prompt-enhancer
✓ Installed tool: env
✓ Installed tool: gemini
ℹ Skipped existing: context:essential-patterns
✓ Installed context: project-context
✓ Installed config: env-example
✓ Installed config: readme
✓ Installation complete!
Installed: 14
Skipped: 8
▶ Next Steps
1. Review the installed components in .opencode/
2. Copy env.example to .env and configure:
cp env.example .env
3. Start using OpenCode agents:
opencode
ℹ Documentation: https://github.com/darrenhinde/opencode-agents
The collision report groups files by type for easy review:
| Category | Location | Description |
|---|---|---|
| Agents | .opencode/agent/*.md |
Main orchestrator agents |
| Subagents | .opencode/agent/subagents/*.md |
Specialized worker agents |
| Commands | .opencode/command/*.md |
Slash commands |
| Tools | .opencode/tool/*/ |
Tool implementations |
| Plugins | .opencode/plugin/*.ts |
Plugin integrations |
| Context | .opencode/context/**/*.md |
Context files |
| Config | Root level files | Configuration files |
registry.json.opencode.backup.YYYYMMDD-HHMMSS/# Delete the specific file first
rm .opencode/agent/task-manager.md
# Run installer again with skip mode
# Only the deleted file will be reinstalled
# If you chose Option 3 (backup), restore from backup:
cp .opencode.backup.*/path/to/file .opencode/path/to/file
# If you chose Option 2 (overwrite), check git history:
git checkout HEAD -- .opencode/
# If you have a backup:
diff .opencode/agent/my-agent.md .opencode.backup.*/agent/my-agent.md
# If you have git:
git diff .opencode/
# Use Option 3 to create backup
# Then manually merge:
vimdiff .opencode/agent/my-agent.md .opencode.backup.*/agent/my-agent.md
Potential improvements for future versions:
The collision handling system provides:
✅ Safety - Never overwrites without asking
✅ Flexibility - Multiple strategies for different needs
✅ Transparency - Clear reporting of what will change
✅ Recoverability - Backup option for peace of mind
✅ Simplicity - Easy to understand and use
Choose the strategy that fits your situation, and install with confidence!