diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac683d43..af6a39c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: - name: Install OpenCode CLI run: | source scripts/lib/opencode-release.sh - download_opencode_to 2.3.0 "$RUNNER_TEMP/opencode/bin/opencode" + download_opencode_to 2.4.2 "$RUNNER_TEMP/opencode/bin/opencode" echo "$RUNNER_TEMP/opencode/bin" >> "$GITHUB_PATH" - name: Verify OpenCode CLI diff --git a/Dockerfile b/Dockerfile index e7f3146a..5f8efade 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,8 +63,8 @@ FROM base AS runner # an arm64 host builds the amd64 platform; 0.12.7 is the newest verified-good # release, so re-verify a bump there before moving it. ARG UV_VERSION=0.12.7 -ARG OPENCODE_VERSION=2.3.0 -ARG OPENCODE_MIN_VERSION=2.3.0 +ARG OPENCODE_VERSION=2.4.2 +ARG OPENCODE_MIN_VERSION=2.4.2 ARG MICROSANDBOX_VERSION=0.7.2 ARG PLAYWRIGHT_VERSION=1.63.0 # Bump TOOLS_CACHEBUST (e.g. via --build-arg) to force a fresh uv/opencode diff --git a/backend/src/routes/oauth.test.ts b/backend/src/routes/oauth.test.ts index 38771476..57258b1a 100644 --- a/backend/src/routes/oauth.test.ts +++ b/backend/src/routes/oauth.test.ts @@ -8,7 +8,7 @@ import { readJson } from '../../test/helpers/read-json' import { createOAuthRoutes } from './oauth' import { createStubOpenCodeClient } from '../../test/helpers/stub-opencode-client' import { FetchOpenCodeClient } from '../services/opencode/client' -import { resolveOpenCode2Binary, startOpenCodeServe } from '../../test/helpers/opencode-binary' +import { resolveOpenCode2Binary, startOpenCodeServe, waitForOpenCodePluginsLoaded } from '../../test/helpers/opencode-binary' import { buildOpenCodeBasicAuth, ClientError } from '@opencode-manager/shared/opencode' import type { IntegrationInfo, IntegrationMethod } from '@opencode-manager/shared/opencode' import type { OpenCodeClient } from '../services/opencode/client' @@ -370,6 +370,7 @@ describe.skipIf(!openCodeBinary)('oauth routes against a real OpenCode 2 server' }) const app = new Hono() app.route('/oauth', createOAuthRoutes(client)) + await waitForOpenCodePluginsLoaded(client) const methodsResponse = await app.request('/oauth/auth-methods') expect(methodsResponse.status).toBe(200) diff --git a/backend/src/routes/providers.test.ts b/backend/src/routes/providers.test.ts index f89ec5e3..d7ce2ed2 100644 --- a/backend/src/routes/providers.test.ts +++ b/backend/src/routes/providers.test.ts @@ -9,7 +9,7 @@ import type { JsonObject, JsonValue } from '@opencode-manager/shared/utils' import { createProvidersRoutes } from './providers' import { createStubOpenCodeClient } from '../../test/helpers/stub-opencode-client' import { FetchOpenCodeClient } from '../services/opencode/client' -import { resolveOpenCode2Binary, startOpenCodeServe } from '../../test/helpers/opencode-binary' +import { resolveOpenCode2Binary, startOpenCodeServe, waitForOpenCodePluginsLoaded } from '../../test/helpers/opencode-binary' import { buildOpenCodeBasicAuth } from '@opencode-manager/shared/opencode' import { ClientError } from '@opencode-manager/shared/opencode' import type { IntegrationInfo } from '@opencode-manager/shared/opencode' @@ -502,7 +502,7 @@ describe.skipIf(!openCodeBinary)('providers routes against a real OpenCode 2 ser const app = new Hono() app.route('/providers', createProvidersRoutes(client)) - await client.api.integration.list() + await waitForOpenCodePluginsLoaded(client) const connectResponse = await app.request('/providers/anthropic/credentials', { method: 'POST', @@ -534,7 +534,7 @@ describe.skipIf(!openCodeBinary)('providers routes against a real OpenCode 2 ser const app = new Hono() app.route('/providers', createProvidersRoutes(client)) - await client.api.integration.list() + await waitForOpenCodePluginsLoaded(client) const rejected = await app.request('/providers/azure/credentials', { method: 'POST', diff --git a/backend/src/services/opencode-server-registry.test.ts b/backend/src/services/opencode-server-registry.test.ts index 0c9a230b..9344c911 100644 --- a/backend/src/services/opencode-server-registry.test.ts +++ b/backend/src/services/opencode-server-registry.test.ts @@ -390,7 +390,7 @@ describe('OpenCodeServerRegistry', () => { describe('test', () => { it('reports a supported version', async () => { - fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.3.0' })) + fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.4.2' })) const result = await registry.test({ baseUrl: 'https://studio.example.com/', @@ -398,7 +398,7 @@ describe('OpenCodeServerRegistry', () => { password: 'super-secret', }) - expect(result).toEqual({ ok: true, version: '2.3.0', versionSupported: true, error: null }) + expect(result).toEqual({ ok: true, version: '2.4.2', versionSupported: true, error: null }) expect(fetchFn.mock.calls[0]?.[0]).toBe('https://studio.example.com/api/info') const headers = new Headers(fetchFn.mock.calls[0]?.[1]?.headers) expect(headers.get('authorization')).toBe(`Basic ${btoa('alice:super-secret')}`) @@ -419,7 +419,7 @@ describe('OpenCodeServerRegistry', () => { username: 'alice', password: 'super-secret', }) - fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.3.0' })) + fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.4.2' })) const result = await registry.test({ serverId: server.id }) @@ -434,7 +434,7 @@ describe('OpenCodeServerRegistry', () => { baseUrl: 'https://studio.example.com', password: 'super-secret', }) - fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.3.0' })) + fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.4.2' })) const result = await registry.test({ baseUrl: 'https://studio.example.com/opencode', @@ -454,7 +454,7 @@ describe('OpenCodeServerRegistry', () => { baseUrl: 'https://studio.example.com', password: 'super-secret', }) - fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.3.0' })) + fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.4.2' })) const result = await registry.test({ baseUrl: 'https://relocated.example.com', @@ -474,7 +474,7 @@ describe('OpenCodeServerRegistry', () => { baseUrl: 'https://studio.example.com', password: 'super-secret', }) - fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.3.0' })) + fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.4.2' })) await registry.test({ baseUrl: 'https://studio.example.com', diff --git a/backend/test/helpers/opencode-binary.test.ts b/backend/test/helpers/opencode-binary.test.ts index f823556b..bc6af6bc 100644 --- a/backend/test/helpers/opencode-binary.test.ts +++ b/backend/test/helpers/opencode-binary.test.ts @@ -4,10 +4,10 @@ import { mkdtemp, rm } from 'fs/promises' import { vi } from 'vitest' import os from 'os' import path from 'path' -import { OPENCODE_SERVER_USERNAME } from '@opencode-manager/shared/opencode' +import { OPENCODE_PINNED_VERSION, OPENCODE_SERVER_USERNAME } from '@opencode-manager/shared/opencode' import { openCodeBinaryCandidates, resolveOpenCode2Binary, startOpenCodeServe, type ServeSpawn } from './opencode-binary' -const SUPPORTED_VERSION = '2.3.0' +const SUPPORTED_VERSION = OPENCODE_PINNED_VERSION const PATH_CANDIDATE = 'opencode' const ABSOLUTE_CANDIDATES = ['/usr/local/bin/opencode', '/opt/opencode/bin/opencode'] diff --git a/backend/test/helpers/opencode-binary.ts b/backend/test/helpers/opencode-binary.ts index a640ddc3..027e0c89 100644 --- a/backend/test/helpers/opencode-binary.ts +++ b/backend/test/helpers/opencode-binary.ts @@ -6,12 +6,14 @@ import { randomBytes } from 'crypto' import os from 'os' import path from 'path' import { z } from 'zod' -import { buildOpenCodeBasicAuth, isSameOpenCodeMajor, isSupportedOpenCodeVersion } from '@opencode-manager/shared/opencode' +import { buildOpenCodeBasicAuth, isSameOpenCodeMajor, isSupportedOpenCodeVersion, type OpenCodeApi } from '@opencode-manager/shared/opencode' import { OPENCODE_SERVICE_SERVE_ARGS, getOpenCodeServiceRegistrationPath, writeOpenCodeServiceSettings } from '../../src/services/opencode-service-mode' const VERSION_TIMEOUT_MS = 5000 const SERVE_READY_TIMEOUT_MS = 60000 const SERVE_POLL_INTERVAL_MS = 250 +const PLUGIN_LOAD_TIMEOUT_MS = 30000 +const PLUGIN_POLL_INTERVAL_MS = 100 const RUN_TIMEOUT_MS = 90000 const STOP_TIMEOUT_MS = 5000 const KILL_CONFIRM_MS = 2000 @@ -44,6 +46,25 @@ function delay(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)) } +export async function waitForOpenCodePluginsLoaded( + client: { api: OpenCodeApi }, + timeoutMs: number = PLUGIN_LOAD_TIMEOUT_MS, +): Promise { + const deadline = Date.now() + timeoutMs + let lastFailure = 'no plugins reported' + while (Date.now() < deadline) { + try { + const { data } = await client.api.plugin.list() + if (data.length > 0) return + lastFailure = 'no plugins reported' + } catch (error) { + lastFailure = String(error) + } + await delay(PLUGIN_POLL_INTERVAL_MS) + } + throw new Error(`OpenCode server plugins did not load within ${timeoutMs}ms: ${lastFailure}`) +} + export function readOpenCodeVersion(binary: string): string | null { const result = spawnSync(binary, ['--version'], { encoding: 'utf8', timeout: VERSION_TIMEOUT_MS }) if (result.status !== 0) return null diff --git a/backend/test/helpers/opencode-server-harness.ts b/backend/test/helpers/opencode-server-harness.ts index 24d4311d..4991f13b 100644 --- a/backend/test/helpers/opencode-server-harness.ts +++ b/backend/test/helpers/opencode-server-harness.ts @@ -23,7 +23,7 @@ import { createStubOpenCodeClient } from './stub-opencode-client' export type OpenCodeServerInfo = Awaited> export const DEFAULT_SERVER_INFO: OpenCodeServerInfo = { - version: '2.3.0', + version: '2.4.2', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' }, diff --git a/backend/test/index.test.ts b/backend/test/index.test.ts index a4879a6c..00f0c45c 100644 --- a/backend/test/index.test.ts +++ b/backend/test/index.test.ts @@ -4,7 +4,7 @@ import { createServer, type Server } from 'node:net' import { join } from 'node:path' import { z } from 'zod' import type { AssistantModeStatus } from '@opencode-manager/shared/types' -import type { OpenCodeLifecycleState, OpenCodeLifecycleStatus } from '@opencode-manager/shared/opencode' +import { OPENCODE_MIN_VERSION, OPENCODE_PINNED_VERSION, type OpenCodeLifecycleState, type OpenCodeLifecycleStatus } from '@opencode-manager/shared/opencode' import type { BackendApp, BackendAppDependencies, @@ -42,8 +42,8 @@ function lifecycleStatus(state: OpenCodeLifecycleState, healthy: boolean): OpenC state, healthy, port: 5551, - version: '2.3.0', - minVersion: '2.3.0', + version: OPENCODE_PINNED_VERSION, + minVersion: OPENCODE_MIN_VERSION, versionSupported: true, lastError: null, activeRecoveryAction: null, @@ -149,7 +149,7 @@ describe('backend app wiring', { timeout: 30000 }, () => { expect(response.status).toBe(200) const body = HealthResponseSchema.parse(await response.json()) expect(body.database).toBe('connected') - expect(body.opencodeMinVersion).toBe('2.3.0') + expect(body.opencodeMinVersion).toBe(OPENCODE_MIN_VERSION) }) it('creates the workspace directories, AGENTS.md and a seed OpenCode config on startup', async () => { diff --git a/backend/test/routes/settings.test.ts b/backend/test/routes/settings.test.ts index 9fb34aa4..f53f7520 100644 --- a/backend/test/routes/settings.test.ts +++ b/backend/test/routes/settings.test.ts @@ -179,8 +179,8 @@ describe('Settings routes', () => { reload = vi.fn(async () => undefined) restart = vi.fn(async () => ({ healthy: true })) manager = { - getVersion: vi.fn(() => '2.3.0'), - fetchVersion: vi.fn(async () => '2.3.0'), + getVersion: vi.fn(() => '2.4.2'), + fetchVersion: vi.fn(async () => '2.4.2'), clearStartupError: vi.fn(), getLastStartupError: vi.fn(() => null), markRestartPending: vi.fn(), @@ -200,7 +200,7 @@ describe('Settings routes', () => { syncManagerGitIdentityConfig: syncIdentity, } fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => { - if (requestUrl(input) === REGISTRY_URL) return registryResponse(['2.3.0']) + if (requestUrl(input) === REGISTRY_URL) return registryResponse(['2.4.2']) return new Response(null, { status: 404 }) }) await writeConfig('opencode.json', '{}') @@ -546,11 +546,11 @@ describe('Settings routes', () => { describe('OpenCode version routes', () => { it('lists supported OpenCode 2 releases with the current version', async () => { fetchMock.mockImplementation(async () => registryResponse( - ['1.18.32', '2.2.7', '2.3.0', '2.3.1', '2.3.0-beta.1', '3.0.0'], - { '2.3.0': '2026-01-02T00:00:00Z', '2.3.1': '2026-01-03T00:00:00Z' }, + ['1.18.32', '2.2.7', '2.4.2', '2.4.3', '2.4.2-beta.1', '3.0.0'], + { '2.4.2': '2026-01-02T00:00:00Z', '2.4.3': '2026-01-03T00:00:00Z' }, )) clearOpenCodeVersionCache() - manager.getVersion = vi.fn(() => '2.3.0') + manager.getVersion = vi.fn(() => '2.4.2') settingsApp = createApp() const res = await settingsApp.request('/opencode-versions') @@ -558,10 +558,10 @@ describe('Settings routes', () => { expect(res.status).toBe(200) await expect(readJson(res, VersionsSchema)).resolves.toEqual({ versions: [ - { version: '2.3.1', tag: 'v2.3.1', name: 'v2.3.1', publishedAt: '2026-01-03T00:00:00Z' }, - { version: '2.3.0', tag: 'v2.3.0', name: 'v2.3.0', publishedAt: '2026-01-02T00:00:00Z' }, + { version: '2.4.3', tag: 'v2.4.3', name: 'v2.4.3', publishedAt: '2026-01-03T00:00:00Z' }, + { version: '2.4.2', tag: 'v2.4.2', name: 'v2.4.2', publishedAt: '2026-01-02T00:00:00Z' }, ], - currentVersion: '2.3.0', + currentVersion: '2.4.2', }) expect(fetchMock).toHaveBeenCalledWith(REGISTRY_URL) }) @@ -586,11 +586,11 @@ describe('Settings routes', () => { }) it.each([ - ['an older installable version', '2.1.1', 'OpenCode upgraded from v2.1.1 to v2.3.0 and restarted'], - ['an unsupported newer major', '3.0.0', 'OpenCode upgraded from v3.0.0 to v2.3.0 and restarted'], + ['an older installable version', '2.1.1', 'OpenCode upgraded from v2.1.1 to v2.4.2 and restarted'], + ['an unsupported newer major', '3.0.0', 'OpenCode upgraded from v3.0.0 to v2.4.2 and restarted'], ])('upgrades from %s', async (_label, currentVersion, expectedMessage) => { manager.getVersion = vi.fn(() => currentVersion) - manager.fetchVersion = vi.fn(async () => '2.3.0') + manager.fetchVersion = vi.fn(async () => '2.4.2') settingsApp = createApp() const res = await settingsApp.request('/opencode-upgrade', { method: 'POST' }) @@ -600,15 +600,15 @@ describe('Settings routes', () => { success: true, upgraded: true, oldVersion: currentVersion, - newVersion: '2.3.0', + newVersion: '2.4.2', message: expectedMessage, }) - expect(installer).toHaveBeenCalledWith('2.3.0') + expect(installer).toHaveBeenCalledWith('2.4.2') expect(restart).toHaveBeenCalledTimes(1) }) it('does not install when the current version is already the latest', async () => { - manager.getVersion = vi.fn(() => '2.3.0') + manager.getVersion = vi.fn(() => '2.4.2') settingsApp = createApp() const res = await settingsApp.request('/opencode-upgrade', { method: 'POST' }) @@ -634,8 +634,8 @@ describe('Settings routes', () => { success: true, upgraded: true, oldVersion: null, - newVersion: '2.3.0', - message: 'OpenCode v2.3.0 installed and restarted', + newVersion: '2.4.2', + message: 'OpenCode v2.4.2 installed and restarted', }) expect(restart).toHaveBeenCalledTimes(1) }) @@ -656,38 +656,38 @@ describe('Settings routes', () => { it('installs a requested version and restarts', async () => { manager.getVersion = vi.fn(() => '2.1.1') - manager.fetchVersion = vi.fn(async () => '2.3.0') + manager.fetchVersion = vi.fn(async () => '2.4.2') settingsApp = createApp() const res = await settingsApp.request('/opencode-install-version', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ version: '2.3.0' }), + body: JSON.stringify({ version: '2.4.2' }), }) expect(res.status).toBe(200) await expect(readJson(res, UpgradeResultSchema)).resolves.toMatchObject({ success: true, oldVersion: '2.1.1', - newVersion: '2.3.0', - message: 'OpenCode changed from v2.1.1 to v2.3.0', + newVersion: '2.4.2', + message: 'OpenCode changed from v2.1.1 to v2.4.2', }) - expect(installer).toHaveBeenCalledWith('2.3.0') + expect(installer).toHaveBeenCalledWith('2.4.2') expect(restart).toHaveBeenCalledTimes(1) }) it('installs the bare version when the request carries a v prefix', async () => { manager.getVersion = vi.fn(() => '2.1.1') - manager.fetchVersion = vi.fn(async () => '2.3.0') + manager.fetchVersion = vi.fn(async () => '2.4.2') settingsApp = createApp() await settingsApp.request('/opencode-install-version', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ version: 'v2.3.0' }), + body: JSON.stringify({ version: 'v2.4.2' }), }) - expect(installer).toHaveBeenCalledWith('2.3.0') + expect(installer).toHaveBeenCalledWith('2.4.2') }) it('reports failure when the installed version is not the requested one', async () => { @@ -698,13 +698,13 @@ describe('Settings routes', () => { const res = await settingsApp.request('/opencode-install-version', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ version: '2.3.0' }), + body: JSON.stringify({ version: '2.4.2' }), }) expect(res.status).toBe(400) const body = await readJson(res, UpgradeResultSchema) expect(body.success).toBe(false) - expect(String(body.details)).toContain('did not result in version 2.3.0') + expect(String(body.details)).toContain('did not result in version 2.4.2') expect(body.newVersion).toBe('2.1.1') }) @@ -713,10 +713,10 @@ describe('Settings routes', () => { ['a missing version', undefined, null], ['a command injection attempt', '1.2.27; cat /etc/passwd; #', null], ['an invalid format', 'invalid', null], - ['a prerelease', '2.3.0-beta.1', null], - ['an OpenCode 1.x version', '1.18.32', 'OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.3.0 <3.0.0'], - ['a version below the supported range', '2.2.7', 'OpenCode 2.2.7 is not supported; OpenCode Manager requires OpenCode >=2.3.0 <3.0.0'], - ['a version above the supported range', '3.0.0', 'OpenCode 3.0.0 is not supported; OpenCode Manager requires OpenCode >=2.3.0 <3.0.0'], + ['a prerelease', '2.4.2-beta.1', null], + ['an OpenCode 1.x version', '1.18.32', 'OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.4.2 <3.0.0'], + ['a version below the supported range', '2.2.7', 'OpenCode 2.2.7 is not supported; OpenCode Manager requires OpenCode >=2.4.2 <3.0.0'], + ['a version above the supported range', '3.0.0', 'OpenCode 3.0.0 is not supported; OpenCode Manager requires OpenCode >=2.4.2 <3.0.0'], ])('rejects %s before installing', async (_label, version, expectedError) => { const res = await settingsApp.request('/opencode-install-version', { method: 'POST', @@ -803,7 +803,7 @@ describe('Settings routes', () => { const res = await settingsApp.request('/opencode-install-version', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ version: '2.3.0' }), + body: JSON.stringify({ version: '2.4.2' }), }) expect(res.status).toBe(400) @@ -813,7 +813,7 @@ describe('Settings routes', () => { it.each([ ['/opencode-upgrade', undefined], - ['/opencode-install-version', JSON.stringify({ version: '2.3.0' })], + ['/opencode-install-version', JSON.stringify({ version: '2.4.2' })], ])('refuses %s while OPENCODE_BIN manages the binary', async (path, body) => { process.env.OPENCODE_BIN = '/usr/local/bin/opencode' diff --git a/backend/test/services/opencode-installer.test.ts b/backend/test/services/opencode-installer.test.ts index 6143588c..c43a63f6 100644 --- a/backend/test/services/opencode-installer.test.ts +++ b/backend/test/services/opencode-installer.test.ts @@ -131,46 +131,46 @@ describe('resolveOpenCodeInstallTarget', () => { describe('installOpenCodeVersion', () => { it('downloads, verifies and installs the requested version', async () => { const homeDirectory = join(workDirectory, 'home') - const archivePath = createArchive(workDirectory, '2.3.0') + const archivePath = createArchive(workDirectory, '2.4.2') const { calls, fetchFn } = createFetch(archivePath) - const installedPath = await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }) + const installedPath = await installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget }) expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory)) - expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-linux-x64.tar.gz']) + expect(calls).toEqual(['https://opencode.ai/files/bin/2.4.2/opencode-linux-x64.tar.gz']) expect(statSync(installedPath).mode & 0o777).toBe(0o755) - expect(readFileSync(installedPath, 'utf-8')).toContain('2.3.0') + expect(readFileSync(installedPath, 'utf-8')).toContain('2.4.2') }) it('requests the musl asset for a musl linux target', async () => { const homeDirectory = join(workDirectory, 'home') - const archivePath = createArchive(workDirectory, '2.3.0') + const archivePath = createArchive(workDirectory, '2.4.2') const { calls, fetchFn } = createFetch(archivePath) - await installOpenCodeVersion('2.3.0', { + await installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: { platform: 'linux', arch: 'arm64', musl: true }, }) - expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-linux-arm64-musl.tar.gz']) + expect(calls).toEqual(['https://opencode.ai/files/bin/2.4.2/opencode-linux-arm64-musl.tar.gz']) }) it('extracts the darwin zip asset and installs it', async () => { const homeDirectory = join(workDirectory, 'home') - const archivePath = createDarwinArchive(workDirectory, '2.3.0') + const archivePath = createDarwinArchive(workDirectory, '2.4.2') const { calls, fetchFn } = createFetch(archivePath) - const installedPath = await installOpenCodeVersion('2.3.0', { + const installedPath = await installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: { platform: 'darwin', arch: 'arm64', musl: false }, }) - expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-darwin-arm64.zip']) + expect(calls).toEqual(['https://opencode.ai/files/bin/2.4.2/opencode-darwin-arm64.zip']) expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory)) expect(statSync(installedPath).mode & 0o777).toBe(0o755) - expect(readFileSync(installedPath, 'utf-8')).toContain('2.3.0') + expect(readFileSync(installedPath, 'utf-8')).toContain('2.4.2') }) it('rejects an OpenCode 1.x version before downloading anything', async () => { @@ -178,18 +178,18 @@ describe('installOpenCodeVersion', () => { const { calls, fetchFn } = createFetch(null) await expect(installOpenCodeVersion('1.18.32', { fetch: fetchFn, homeDirectory, target: linuxTarget })) - .rejects.toThrow('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.3.0 <3.0.0') + .rejects.toThrow('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.4.2 <3.0.0') expect(calls).toEqual([]) }) - it.each(['2.2.7', '3.0.0', '2.3.0-beta.1', '2.3.0; rm -rf /'])( + it.each(['2.2.7', '3.0.0', '2.4.2-beta.1', '2.4.2; rm -rf /'])( 'rejects %s outside the supported stable range before downloading anything', async (version) => { const homeDirectory = join(workDirectory, 'home') const { calls, fetchFn } = createFetch(null) await expect(installOpenCodeVersion(version, { fetch: fetchFn, homeDirectory, target: linuxTarget })) - .rejects.toThrow(/requires OpenCode >=2\.3\.0 <3\.0\.0/) + .rejects.toThrow(/requires OpenCode >=2\.4\.2 <3\.0\.0/) expect(calls).toEqual([]) }, ) @@ -198,18 +198,18 @@ describe('installOpenCodeVersion', () => { const homeDirectory = join(workDirectory, 'home') const { fetchFn } = createFetch(null, 404) - await expect(installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })) + await expect(installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget })) .rejects.toThrow(/404/) expect(() => statSync(resolveOpenCodeBinaryPath(homeDirectory))).toThrow() }) it('fails and leaves no binary behind when the archive reports a different version', async () => { const homeDirectory = join(workDirectory, 'home') - const archivePath = createArchive(workDirectory, '2.3.1') + const archivePath = createArchive(workDirectory, '2.4.3') const { fetchFn } = createFetch(archivePath) - await expect(installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })) - .rejects.toThrow(/2\.3\.0/) + await expect(installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget })) + .rejects.toThrow(/2\.4\.2/) expect(() => statSync(resolveOpenCodeBinaryPath(homeDirectory))).toThrow() }) @@ -218,21 +218,21 @@ describe('installOpenCodeVersion', () => { mkdirSync(join(homeDirectory, '.opencode', 'bin'), { recursive: true }) writeFileSync(resolveOpenCodeBinaryPath(homeDirectory), '#!/bin/sh\necho "opencode v2.1.1"\n') - const archivePath = createArchive(workDirectory, '2.3.0') + const archivePath = createArchive(workDirectory, '2.4.2') const { fetchFn } = createFetch(archivePath) - await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }) + await installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget }) - expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.3.0') + expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.4.2') }) it('cleans up its staging directory after a successful install', async () => { const homeDirectory = join(workDirectory, 'home') - const archivePath = createArchive(workDirectory, '2.3.0') + const archivePath = createArchive(workDirectory, '2.4.2') const { fetchFn } = createFetch(archivePath) const before = countStagingDirectories() - await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }) + await installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget }) expect(countStagingDirectories()).toBe(before) }) @@ -244,15 +244,15 @@ describe('listOpenCodeVersions', () => { '1.18.32': {}, '2.0.14': {}, '2.1.1': {}, - '2.3.0': {}, - '2.3.1': {}, - '2.3.0-beta.1': {}, + '2.4.2': {}, + '2.4.3': {}, + '2.4.2-beta.1': {}, '3.0.0': {}, 'not-a-version': {}, }, time: { - '2.3.0': '2026-02-01T00:00:00.000Z', - '2.3.1': '2026-03-01T00:00:00.000Z', + '2.4.2': '2026-02-01T00:00:00.000Z', + '2.4.3': '2026-03-01T00:00:00.000Z', }, } @@ -262,20 +262,20 @@ describe('listOpenCodeVersions', () => { const versions = await listOpenCodeVersions({ fetch: fetchFn }) expect(versions).toEqual([ - { version: '2.3.1', publishedAt: '2026-03-01T00:00:00.000Z' }, - { version: '2.3.0', publishedAt: '2026-02-01T00:00:00.000Z' }, + { version: '2.4.3', publishedAt: '2026-03-01T00:00:00.000Z' }, + { version: '2.4.2', publishedAt: '2026-02-01T00:00:00.000Z' }, ]) expect(calls).toEqual(['https://registry.npmjs.org/@opencode/cli']) }) it('reports a null publishedAt when the registry has no timestamp for a version', async () => { const { fetchFn } = createRegistryFetch({ - versions: { '2.3.0': {} }, + versions: { '2.4.2': {} }, time: {}, }) await expect(listOpenCodeVersions({ fetch: fetchFn })).resolves.toEqual([ - { version: '2.3.0', publishedAt: null }, + { version: '2.4.2', publishedAt: null }, ]) }) @@ -293,14 +293,14 @@ describe('listOpenCodeVersions', () => { it('refreshes the list once the five minute cache expires', async () => { const stale = createRegistryFetch(registryPayload) - const fresh = createRegistryFetch({ versions: { '2.3.1': {} }, time: {} }) + const fresh = createRegistryFetch({ versions: { '2.4.3': {} }, time: {} }) let now = 1_000_000 await listOpenCodeVersions({ fetch: stale.fetchFn, now: () => now }) now += 5 * 60 * 1000 const refreshed = await listOpenCodeVersions({ fetch: fresh.fetchFn, now: () => now }) - expect(refreshed).toEqual([{ version: '2.3.1', publishedAt: null }]) + expect(refreshed).toEqual([{ version: '2.4.3', publishedAt: null }]) expect(stale.calls).toHaveLength(1) expect(fresh.calls).toHaveLength(1) }) @@ -331,7 +331,7 @@ describe('OpenCodeInstallError swap signalling', () => { const homeDirectory = join(workDirectory, 'home') const { fetchFn } = createFetch(null, 404) - const promise = installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }) + const promise = installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget }) await expect(promise).rejects.toBeInstanceOf(OpenCodeInstallError) await expect(promise).rejects.toMatchObject({ swapStarted: false }) @@ -341,10 +341,10 @@ describe('OpenCodeInstallError swap signalling', () => { it('marks a failure while replacing the binary as having started the binary swap', async () => { const homeDirectory = join(workDirectory, 'home') mkdirSync(resolveOpenCodeBinaryPath(homeDirectory), { recursive: true }) - const archivePath = createArchive(workDirectory, '2.3.0') + const archivePath = createArchive(workDirectory, '2.4.2') const { fetchFn } = createFetch(archivePath) - const promise = installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }) + const promise = installOpenCodeVersion('2.4.2', { fetch: fetchFn, homeDirectory, target: linuxTarget }) await expect(promise).rejects.toBeInstanceOf(OpenCodeInstallError) await expect(promise).rejects.toMatchObject({ swapStarted: true }) diff --git a/backend/test/services/opencode-single-server.test.ts b/backend/test/services/opencode-single-server.test.ts index 74c1ca97..68a357fc 100644 --- a/backend/test/services/opencode-single-server.test.ts +++ b/backend/test/services/opencode-single-server.test.ts @@ -703,12 +703,12 @@ describe('OpenCodeServerManager - plugins and version', () => { it.each([true, false])('starts on a supported OpenCode 2 build (enforced: %s)', async (enforced) => { context.harness.sandbox.enabled = enforced context.harness.ownPortAfterSpawn() - context.harness.readVersionOutput.mockReturnValue({ stdout: 'opencode v2.3.0\n', stderr: '' }) + context.harness.readVersionOutput.mockReturnValue({ stdout: 'opencode v2.4.2\n', stderr: '' }) await context.harness.manager.start() expect(context.harness.spawnServer).toHaveBeenCalledTimes(1) - expect(context.harness.manager.getVersion()).toBe('2.3.0') + expect(context.harness.manager.getVersion()).toBe('2.4.2') expect(context.harness.manager.isVersionSupported()).toBe(true) }) @@ -717,7 +717,7 @@ describe('OpenCodeServerManager - plugins and version', () => { await expect(context.harness.manager.start()).rejects.toThrow('OpenCode 1.18.32 is not supported') expect(context.harness.spawnServer).not.toHaveBeenCalled() - expect(context.harness.manager.getLastStartupError()).toContain('requires OpenCode >=2.3.0 <3.0.0') + expect(context.harness.manager.getLastStartupError()).toContain('requires OpenCode >=2.4.2 <3.0.0') expect(context.harness.manager.isLastStartupErrorNonRecoverable()).toBe(true) }) }) diff --git a/backend/test/shared/opencode-contract.test.ts b/backend/test/shared/opencode-contract.test.ts index ba7fadba..d9e6dff8 100644 --- a/backend/test/shared/opencode-contract.test.ts +++ b/backend/test/shared/opencode-contract.test.ts @@ -52,10 +52,10 @@ function createFetchSpy() { describe('OpenCode v2 contract', () => { describe('version policy', () => { it('pins the built-against version, keeps a separate supported floor and fixes the V2 server username', () => { - expect(OPENCODE_PINNED_VERSION).toBe('2.3.0') - expect(OPENCODE_MIN_VERSION).toBe('2.3.0') + expect(OPENCODE_PINNED_VERSION).toBe('2.4.2') + expect(OPENCODE_MIN_VERSION).toBe('2.4.2') expect(compareOpenCodeVersions(OPENCODE_PINNED_VERSION, OPENCODE_MIN_VERSION)).toBeGreaterThanOrEqual(0) - expect(OPENCODE_SUPPORTED_VERSION_RANGE).toBe('>=2.3.0 <3.0.0') + expect(OPENCODE_SUPPORTED_VERSION_RANGE).toBe('>=2.4.2 <3.0.0') expect(OPENCODE_SERVER_USERNAME).toBe('opencode') }) @@ -69,40 +69,42 @@ describe('OpenCode v2 contract', () => { expect(isSupportedOpenCodeVersion('2.2.4')).toBe(false) expect(isSupportedOpenCodeVersion('2.2.5')).toBe(false) expect(isSupportedOpenCodeVersion('2.2.6')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0')).toBe(true) - expect(isSupportedOpenCodeVersion('2.3.1')).toBe(true) - expect(isSupportedOpenCodeVersion('v2.3.0')).toBe(true) - expect(isSupportedOpenCodeVersion(' v2.3.0 ')).toBe(true) + expect(isSupportedOpenCodeVersion('2.3.0')).toBe(false) + expect(isSupportedOpenCodeVersion('2.3.1')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2')).toBe(true) + expect(isSupportedOpenCodeVersion('2.4.3')).toBe(true) + expect(isSupportedOpenCodeVersion('v2.4.2')).toBe(true) + expect(isSupportedOpenCodeVersion(' v2.4.2 ')).toBe(true) expect(isSupportedOpenCodeVersion('3.0.0')).toBe(false) expect(isSupportedOpenCodeVersion('3.1.0')).toBe(false) expect(isSupportedOpenCodeVersion('not-a-version')).toBe(false) }) it('rejects prereleases of the pinned version', () => { - expect(isSupportedOpenCodeVersion('2.3.0-alpha.1')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0-alpha')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0-rc.1+build.5')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0-0')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2-alpha.1')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2-alpha')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2-rc.1+build.5')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2-0')).toBe(false) }) it('accepts prereleases of higher numeric cores within the pinned major', () => { - expect(isSupportedOpenCodeVersion('2.3.1-beta.1')).toBe(true) - expect(isSupportedOpenCodeVersion('2.3.1-rc.2')).toBe(true) + expect(isSupportedOpenCodeVersion('2.4.3-beta.1')).toBe(true) + expect(isSupportedOpenCodeVersion('2.4.3-rc.2')).toBe(true) expect(isSupportedOpenCodeVersion('3.0.0-beta.1')).toBe(false) }) it('ignores build metadata for precedence', () => { - expect(isSupportedOpenCodeVersion('2.3.0+build')).toBe(true) - expect(isSupportedOpenCodeVersion('2.3.0+2.0.0')).toBe(true) + expect(isSupportedOpenCodeVersion('2.4.2+build')).toBe(true) + expect(isSupportedOpenCodeVersion('2.4.2+2.0.0')).toBe(true) }) it('rejects malformed and incomplete versions', () => { expect(isSupportedOpenCodeVersion('2garbage')).toBe(false) expect(isSupportedOpenCodeVersion('2')).toBe(false) expect(isSupportedOpenCodeVersion('2.0')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0.1')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2.1')).toBe(false) expect(isSupportedOpenCodeVersion('02.2.1')).toBe(false) - expect(isSupportedOpenCodeVersion('2.3.0-alpha..1')).toBe(false) + expect(isSupportedOpenCodeVersion('2.4.2-alpha..1')).toBe(false) expect(isSupportedOpenCodeVersion('')).toBe(false) }) @@ -117,7 +119,7 @@ describe('OpenCode v2 contract', () => { 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.3.0 <3.0.0', + 'OpenCode 3.0.0 is not supported; OpenCode Manager requires OpenCode >=2.4.2 <3.0.0', ) }) }) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index afce8604..c5911384 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -143,6 +143,7 @@ function RootLayout() { +