Thin wrapper repo: local patches on upstream OpenCode.
~/opencode-custom/
├── patches/*.patch # local patches (tracked)
├── update-and-build.sh # build script (tracked)
├── state/current-tag # active version (gitignored)
├── opencode/ # shallow clone + build (gitignored)
└── logs/ # failure reports (gitignored)
cd ~/opencode-custom
./update-and-build.sh # update to latest upstream tag
./update-and-build.sh --reset # nuke all local state, rebuild from scratch
./update-and-build.sh --tag v1.2.0 # build a specific versionOn a fresh machine:
git clone <this-repo> ~/opencode-custom
cd ~/opencode-custom
./update-and-build.sh
# If bun is missing, the script installs it automatically.
# Binary is symlinked to ~/.opencode/bin/opencode- Queries latest upstream tag via
git ls-remote(no local upstream remote needed). - Shallow-clones the target tag into
opencode/. - Applies all
patches/*.patchin sorted order viagit apply. - Runs
bun install && bun run --cwd packages/opencode build. - Verifies the built binary exists and symlinks
~/.opencode/bin/opencodeto it. - On failure: build dir left for inspection, previous binary untouched.
The build dir is a fully independent shallow clone. No shared git state, no branch management.
- Built binary (macOS arm64):
~/opencode-custom/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode - System symlink:
~/.opencode/bin/opencode→ built binary
Current:
patches/fix-claude-thinking-blocks.patchpatches/fix-gemini-finish-reason.patch
Patches are applied in alphabetical order. Prefix with NNN- for deterministic ordering.
If a patch fails to apply:
- Script stops immediately.
- A failure report is written to
logs/patch-failure_<tag>_<timestamp>_<patchname>.md. - The build dir is left as-is for manual inspection.
- Inspect the build dir:
cd ~/opencode-custom/opencode
git status- Fix the patch conflicts, then validate:
bun install && bun run --cwd packages/opencode build- Regenerate the patch:
git diff HEAD -- <files-you-changed> > ~/opencode-custom/patches/<patch-name>.patch- Re-run:
cd ~/opencode-custom
./update-and-build.sh --reset- Wrapper
maincontains only patches, script, and docs. - All local modifications are expressed as
patches/*.patch. - Build dir (
opencode/) is a disposable shallow clone. - Never vendor upstream source into this repo.