This document explains how to keep the skycode-opencode fork synchronized with the upstream OpenCode repository.
Key Principle: Keep Fork Minimal for Easy Syncing
- Plugins Location: SkyCode plugins are NOT in this fork
- Plugins Location: Plugins live in
skycode/packages/opencode-plugin/(main repo) - Fork Purpose: Version control, major incompatible changes, and OpenCode customization
- Minimal Changes: Keep fork as close to upstream as possible
- Easy Upstream Syncs: Minimal changes in fork = fewer conflicts
- Plugin Maintenance: Plugins evolve separately from OpenCode
- Version Control: Fork controls OpenCode version bundled with SkyCode
- Clean Separation: Core OpenCode changes vs. SkyCode extensions
cd skycode-opencode
./sync-upstream.shcd skycode-opencode
git remote add upstream https://github.com/sst/opencode.git
git remote -v # Verify remotesgit fetch upstream# Switch to your working branch (e.g., main or dev)
git checkout dev # or your branch name
# Merge upstream changes
git merge upstream/mainIf there are conflicts:
# Resolve conflicts in files
git status # See conflicted files
# Edit files to resolve conflicts
# After resolving:
git add .
git commit -m "Merge upstream: resolve conflicts"git push origin devThe sync-upstream.sh script automates the sync process:
cd skycode-opencode
./sync-upstream.shWhat it does:
- Checks for upstream remote (adds if missing)
- Fetches upstream changes
- Stashes local uncommitted changes (if any)
- Merges upstream/main into current branch
- Restores stashed changes
- Shows summary
- Monthly: Regular syncs to get upstream bug fixes and features
- As Needed: When upstream releases important features or fixes
- dev: SkyCode's development branch (sync with upstream/main)
- main: Stable branch (sync before releases)
- feature/*: Feature branches (sync before merging)
In Fork (skycode-opencode):
- ✅ Version pinning/compatibility changes
- ✅ Major incompatible behavior changes (rare)
- ✅ OpenCode core modifications needed for SkyCode
- ✅ Build configuration for bundling
In Main Repo (skycode):
- ✅ All SkyCode plugins (
packages/opencode-plugin/) - ✅ Plugin loading/integration logic
- ✅ SkyCode-specific configurations
- ✅ Settings import logic
When conflicts occur:
-
Keep Minimal Changes in Fork:
- Only essential OpenCode core changes
- Version compatibility fixes
- Bundling-related modifications
-
Move to Main Repo When Possible:
- Plugin-related changes → Main repo
- Configuration changes → Main repo
- Integration logic → Main repo
-
Merge Both (when applicable):
- Documentation updates
- Bug fixes that don't conflict
Since plugins are in the main repo, they're loaded via:
- Build Time: Bundle plugin with SkyCode
- Runtime: OpenCode loads plugin from bundled location
- Configuration: Point OpenCode to SkyCode plugin location
Plugin Path: skycode/packages/opencode-plugin/
# Check commits ahead/behind upstream
git log upstream/main..HEAD # Our commits not in upstream
git log HEAD..upstream/main # Upstream commits we don't have
# Check diff summary
git diff --stat upstream/main..HEAD
# Should show minimal differences (only essential changes)git remote add upstream https://github.com/sst/opencode.git# See conflicted files
git status
# Use merge tool
git mergetool
# After resolving, complete merge
git add .
git commitIf fork has drifted significantly:
-
Create backup branch:
git branch backup-before-reset
-
Reset to upstream (if changes are in main repo):
git fetch upstream git reset --hard upstream/main
-
Re-apply only essential changes:
- Re-add version pinning
- Re-add bundling changes
- Verify everything still works
# Update remote URL if needed
git remote set-url upstream https://github.com/sst/opencode.git
# Verify
git remote -v- Sync Regularly: Don't let fork get too far behind
- Keep Changes Minimal: Only essential changes in fork
- Move to Main Repo: When possible, keep changes in main repo
- Test After Sync: Run tests to ensure nothing broke
- Document Fork Changes: Keep track of what's different and why
- Small Incremental Syncs: Sync monthly rather than yearly
Consider adding automated sync checks:
- Weekly check for upstream updates
- Notification when upstream has changes
- Automated test runs after sync
- Automated conflict detection
- Architecture:
skycode/docs/architecture/opencode-integration-architecture.md - Plugin Implementation:
skycode/docs/plans/opencode-bundled-implementation.md - Plugin Code:
skycode/packages/opencode-plugin/