From bf7c6cdbac7eba27ec98dfff6123ad4e14eba291 Mon Sep 17 00:00:00 2001
From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
Date: Fri, 6 Nov 2026 09:43:35 -0500
Subject: [PATCH] fix(opencode): address review feedback on the 2.2.5 pin
Document ocm 0.6.x as requiring OpenCode 2.2.5, matching its
@opencode/theme peer, and make the package compatibility test check
bounded peer ranges instead of treating them as one version.
Linked servers on another 2.x release keep the neutral version notice,
while a different major version is shown as unsupported again through
a shared version badge.
The Docker build now fails when the bundled OpenCode is below the
supported minimum, and the entrypoint falls back to the bundled version
as the floor when OPENCODE_MIN_VERSION is unset instead of discarding
every persisted binary.
---
Dockerfile | 2 ++
.../test/scripts/docker-entrypoint.test.ts | 16 ++++++++++++++--
backend/test/shared/opencode-contract.test.ts | 12 +++++++++++-
.../settings/OpenCodeServerDialog.tsx | 16 +++++++++++-----
.../settings/OpenCodeServersSettings.tsx | 8 ++------
ocm-cli/README.md | 8 ++++----
ocm-cli/test/package-compat.test.ts | 19 ++++++++++++++-----
scripts/docker-entrypoint.sh | 2 +-
shared/src/opencode/index.ts | 1 +
shared/src/opencode/release.ts | 5 +++++
10 files changed, 65 insertions(+), 24 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index ab217a4c..d1e5aae1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -80,6 +80,8 @@ RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION} (cachebust=${
chmod +x /usr/local/bin/uv /usr/local/bin/uvx && \
test "$(uv --version | cut -d' ' -f2)" = "${UV_VERSION}" && \
. /usr/local/lib/ocm/opencode-release.sh && \
+ OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION}" && \
+ { is_supported_opencode_version "${OPENCODE_VERSION}" || { echo "OPENCODE_VERSION ${OPENCODE_VERSION} is outside the supported range $(supported_opencode_range)" >&2; exit 1; }; } && \
echo "Downloading opencode ${OPENCODE_VERSION}..." && \
download_opencode_to "${OPENCODE_VERSION}" /opt/opencode/bin/opencode && \
ln -s /opt/opencode/bin/opencode /usr/local/bin/opencode && \
diff --git a/backend/test/scripts/docker-entrypoint.test.ts b/backend/test/scripts/docker-entrypoint.test.ts
index cad3ae0f..9c778dd7 100644
--- a/backend/test/scripts/docker-entrypoint.test.ts
+++ b/backend/test/scripts/docker-entrypoint.test.ts
@@ -460,14 +460,26 @@ exit 1`)
expect(curlLog()).toHaveLength(0)
})
- it('treats every persisted binary as unsupported when the minimum version is unknown', () => {
+ it('treats every persisted binary as unsupported when neither the minimum nor the bundled version is known', () => {
+ mkdirSync(join(stubDir, 'home/.opencode/bin'), { recursive: true })
+ writeBinary(join(stubDir, 'home/.opencode/bin'), '2.0.15')
+ const res = runOpenCodeSection(`${installPrelude()}\nreconcile_persisted_opencode`, {
+ OPENCODE_MIN_VERSION: '',
+ OPENCODE_BUNDLED_VERSION: '',
+ })
+ expect(res.status).toBe(0)
+ expect(existsSync(homeBinPath())).toBe(false)
+ })
+
+ it('falls back to the bundled version as the floor when the minimum is unset', () => {
mkdirSync(join(stubDir, 'home/.opencode/bin'), { recursive: true })
writeBinary(join(stubDir, 'home/.opencode/bin'), '2.0.15')
const res = runOpenCodeSection(`${installPrelude()}\nreconcile_persisted_opencode`, {
OPENCODE_MIN_VERSION: '',
})
expect(res.status).toBe(0)
- expect(existsSync(homeBinPath())).toBe(false)
+ expect(res.stdout).toContain('Persisted OpenCode 2.0.15 is usable; retaining it')
+ expect(existsSync(homeBinPath())).toBe(true)
})
it('removes a malformed persisted home binary and selects the bundled binary without downloading', () => {
diff --git a/backend/test/shared/opencode-contract.test.ts b/backend/test/shared/opencode-contract.test.ts
index 0b00dd66..9e6130e0 100644
--- a/backend/test/shared/opencode-contract.test.ts
+++ b/backend/test/shared/opencode-contract.test.ts
@@ -11,6 +11,7 @@ import {
compareOpenCodeVersions,
createOpenCodeApi,
describeUnsupportedOpenCodeVersion,
+ isSameOpenCodeMajor,
isStableOpenCodeVersion,
isSupportedOpenCodeVersion,
normalizeOpenCodeVersion,
@@ -104,6 +105,15 @@ describe('OpenCode v2 contract', () => {
expect(isSupportedOpenCodeVersion('')).toBe(false)
})
+ it('treats any release of the same major as reachable, regardless of the floor', () => {
+ expect(isSameOpenCodeMajor('2.0.15')).toBe(true)
+ expect(isSameOpenCodeMajor('2.2.4')).toBe(true)
+ expect(isSameOpenCodeMajor('2.9.0')).toBe(true)
+ expect(isSameOpenCodeMajor('1.18.32')).toBe(false)
+ expect(isSameOpenCodeMajor('3.0.0')).toBe(false)
+ expect(isSameOpenCodeMajor('not-a-version')).toBe(false)
+ })
+
it('describes the supported range for unsupported versions', () => {
expect(describeUnsupportedOpenCodeVersion('3.0.0')).toBe(
'OpenCode 3.0.0 is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0',
@@ -174,7 +184,7 @@ describe('OpenCode v2 contract', () => {
const entrypoint = readFileSync(join(REPO_ROOT, 'scripts', 'docker-entrypoint.sh'), 'utf8')
const setupDev = readFileSync(join(REPO_ROOT, 'scripts', 'setup-dev.sh'), 'utf8')
const releaseHelper = readFileSync(join(REPO_ROOT, 'scripts', 'lib', 'opencode-release.sh'), 'utf8')
- expect(entrypoint).toContain('OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION:-}"')
+ expect(entrypoint).toContain('OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION:-${OPENCODE_BUNDLED_VERSION:-}}"')
expect(setupDev).toContain("sed -n 's/^ARG OPENCODE_MIN_VERSION=//p' \"$REPO_ROOT/Dockerfile\"")
for (const script of [entrypoint, setupDev, releaseHelper]) {
expect(script).not.toMatch(/(?Supported
+ if (result.version && isSameOpenCodeMajor(result.version)) {
+ return