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.
This commit is contained in:
Chris Scott committed 2026-11-06 09:43:35 -05:00
1 parent 807c7cb896
commit bf7c6cdbac
10 files changed
+65 -24

No files matched your search

+2
View File
@@ -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 && \
+14 -2
View File
@@ -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', () => {
+11 -1
View File
@@ -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(/(?<![\d.])\d+\.\d+\.\d+(?![\d.])/)
@@ -12,6 +12,7 @@ import {
type OpenCodeServerLink,
type OpenCodeServerTestResult,
} from '@opencode-manager/shared/schemas'
import { isSameOpenCodeMajor } from '@opencode-manager/shared/opencode'
import { haveSameUrlOrigin, isPublicPlainHttpUrl, parseHttpUrl } from '@opencode-manager/shared/utils'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
@@ -99,6 +100,15 @@ function buildDefaultValues(server?: OpenCodeServer | null): ServerFormValues {
}
}
/** Labels a reachable server's version: supported, same major but different, or an incompatible major. */
export function OpenCodeVersionBadge({ result }: { result: OpenCodeServerTestResult }) {
if (result.versionSupported) return <Badge variant="secondary">Supported</Badge>
if (result.version && isSameOpenCodeMajor(result.version)) {
return <Badge variant="outline">Different version: some features may not work</Badge>
}
return <Badge variant="destructive">Unsupported version</Badge>
}
function TestResultSummary({ result }: { result: OpenCodeServerTestResult }) {
if (!result.ok) {
return (
@@ -112,11 +122,7 @@ function TestResultSummary({ result }: { result: OpenCodeServerTestResult }) {
<div role="status" className="flex flex-wrap items-center gap-2 rounded-md border border-border p-2 text-sm">
<CheckCircle2 className="h-4 w-4 shrink-0 text-success" />
<span>Connected — OpenCode {result.version ?? 'unknown version'}</span>
{result.versionSupported ? (
<Badge variant="secondary">Supported</Badge>
) : (
<Badge variant="outline">Different version: some features may not work</Badge>
)}
<OpenCodeVersionBadge result={result} />
</div>
)
}
@@ -12,7 +12,7 @@ import { Switch } from '@/components/ui/switch'
import { DeleteDialog } from '@/components/ui/delete-dialog'
import { showToast } from '@/lib/toast'
import { useOpenCodeServers } from '@/hooks/useOpenCodeServers'
import { OpenCodeServerDialog, type OpenCodeServerFormValues } from './OpenCodeServerDialog'
import { OpenCodeServerDialog, OpenCodeVersionBadge, type OpenCodeServerFormValues } from './OpenCodeServerDialog'
function errorMessage(error: unknown, fallback: string): string {
return error instanceof Error && error.message ? error.message : fallback
@@ -31,11 +31,7 @@ function ServerTestResult({ result }: { result: OpenCodeServerTestResult }) {
<div className="flex flex-wrap items-center gap-2 text-sm">
<CheckCircle2 className="h-4 w-4 shrink-0 text-success" />
<span>OpenCode {result.version ?? 'unknown version'}</span>
{result.versionSupported ? (
<Badge variant="secondary">Supported</Badge>
) : (
<Badge variant="outline">Different version: some features may not work</Badge>
)}
<OpenCodeVersionBadge result={result} />
</div>
)
}
+4 -4
View File
@@ -10,7 +10,7 @@ to the local working tree.
| ocm | OpenCode Manager | Local OpenCode |
|---|---|---|
| 0.6.x | >= 0.19.0 | >= 2.2.3, < 3 |
| 0.6.x | >= 0.19.0 | >= 2.2.5, < 3 |
| 0.5.x | >= 0.19.0 | >= 2.2.0, < 3 |
| 0.4.x | >= 0.19.0 | >= 2.0.15, < 3 |
| 0.3.x | >= 0.19.0 | >= 2.0.15, < 3 |
@@ -26,8 +26,8 @@ Use ocm 0.2.x with OpenCode Manager < 0.19.0 and OpenCode 1.x, installed pinned
release.
From ocm 0.6.0, the TUI plugin is built against `@opencode/plugin` 2.2.5 and
OpenTUI 0.8, so it requires a local OpenCode >= 2.2.3. OpenCode 2.2.0 through
2.2.2 ship OpenTUI 0.7; stay on ocm 0.5.x with those builds. ocm 0.5.0 itself
OpenTUI 0.8 and declares an `@opencode/theme` peer of `>=2.2.5`, so it requires
a local OpenCode >= 2.2.5. Stay on ocm 0.5.x with an older 2.2.x. ocm 0.5.0 itself
is built against `@opencode/plugin` 2.2.1 and OpenTUI 0.7 and requires a local
OpenCode >= 2.2.0: OpenCode 2.2.0 refuses plugins built for OpenTUI 0.6, and
older OpenCode builds may refuse the 0.7 peers. Stay on ocm 0.4.x with a local
@@ -324,7 +324,7 @@ global installs); the plugin surface is TUI-only.
## Requirements
- macOS or Linux (Windows is unsupported)
- OpenCode >= 2.2.3 (same major, 2.x) available on `PATH` for the TUI plugin
- OpenCode >= 2.2.5 (same major, 2.x) available on `PATH` for the TUI plugin
- Node available on `PATH` (runs the `ocm` binary)
- OpenCode Manager >= 0.19.0
- `git` and `tar` (with gzip support, i.e. the `-z` flag) available on `PATH`
+14 -5
View File
@@ -45,15 +45,24 @@ function deriveMinorLineRange(version: string): string {
}
/**
* Asserts that an installed version satisfies a plugin peer declaration,
* accepting both an exact peer pin and an open `>=` floor.
* Asserts that an installed version satisfies a plugin peer declaration: an exact
* pin, or space-separated `>=`, `<=` and `<` bounds such as `>=0.8.0 <0.9.0`.
*/
function expectVersionSatisfiesPeer(version: string, peer: string): void {
if (peer.startsWith('>=')) {
expect(compareSemver(version, peer.slice(2).trim())).toBeGreaterThanOrEqual(0)
const comparators = peer.trim().split(/\s+/)
if (!comparators.every((comparator) => comparator.startsWith('>=') || comparator.startsWith('<'))) {
expect(version).toBe(peer)
return
}
expect(version).toBe(peer)
for (const comparator of comparators) {
if (comparator.startsWith('>=')) {
expect(compareSemver(version, comparator.slice(2))).toBeGreaterThanOrEqual(0)
} else if (comparator.startsWith('<=')) {
expect(compareSemver(version, comparator.slice(2))).toBeLessThanOrEqual(0)
} else {
expect(compareSemver(version, comparator.slice(1))).toBeLessThan(0)
}
}
}
const ocmManifest = readManifest(join(__dirname, '..', 'package.json'))
+1 -1
View File
@@ -60,7 +60,7 @@ ensure_auth_secret() {
export AUTH_SECRET
}
OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION:-}"
OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION:-${OPENCODE_BUNDLED_VERSION:-}}"
read_opencode_version() {
local binary output
+1
View File
@@ -143,6 +143,7 @@ export {
compareOpenCodeVersions,
describeUnsupportedOpenCodeVersion,
isStableOpenCodeVersion,
isSameOpenCodeMajor,
isSupportedOpenCodeVersion,
normalizeOpenCodeVersion,
parseOpenCodeVersion,
+5
View File
@@ -67,6 +67,11 @@ export function isSupportedOpenCodeVersion(version: string): boolean {
return parsed.major === OPENCODE_MIN.major && compareParsedSemver(parsed, OPENCODE_MIN) >= 0
}
/** Reports whether a server version shares Manager's OpenCode major, so the V2 client can still talk to it. */
export function isSameOpenCodeMajor(version: string): boolean {
return parseOpenCodeVersion(version)?.major === OPENCODE_MIN.major
}
export function describeUnsupportedOpenCodeVersion(version: string): string {
return `OpenCode ${version} is not supported; OpenCode Manager requires OpenCode ${OPENCODE_SUPPORTED_VERSION_RANGE}`
}