mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
chore(opencode): move the OpenCode pin to 2.2.5 from a workspace catalog
Manager builds against and requires OpenCode 2.2.5. Every @opencode package, plus effect and the OpenTUI/solid dependencies they share, resolves from one pnpm workspace catalog instead of separate pins. The built-against version and the supported floor are now separate settings, so a future OpenCode release can move the pin before raising the floor. Docker and the dev setup script read the floor from its own argument. ocm-cli moves to 0.6.0 on the same 2.2.5 and OpenTUI 0.8 baseline. A linked server on a different version is still connectable and now shows a neutral version notice instead of an unsupported badge.
This commit is contained in:
1 parent
dc0220843e
commit
807c7cb896
20 files changed
+583
-562
No files matched your search
+3
-1
@@ -63,7 +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.2.1
|
||||
ARG OPENCODE_VERSION=2.2.5
|
||||
ARG OPENCODE_MIN_VERSION=2.2.5
|
||||
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
|
||||
@@ -120,6 +121,7 @@ ENV DATABASE_PATH=/app/data/opencode.db
|
||||
ENV WORKSPACE_PATH=/workspace
|
||||
ENV XDG_CACHE_HOME=/home/node/.cache
|
||||
ENV OPENCODE_BUNDLED_VERSION=${OPENCODE_VERSION}
|
||||
ENV OPENCODE_MIN_VERSION=${OPENCODE_MIN_VERSION}
|
||||
ENV MSB_PATH=/usr/local/bin/msb
|
||||
ENV MSB_LIBKRUNFW_PATH=/opt/microsandbox/lib/libkrunfw.so
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
|
||||
@@ -449,7 +449,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
|
||||
describe('test', () => {
|
||||
it('reports a supported version', async () => {
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.1' }))
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.5' }))
|
||||
|
||||
const result = await registry.test({
|
||||
baseUrl: 'https://studio.example.com/',
|
||||
@@ -457,7 +457,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
password: 'super-secret',
|
||||
})
|
||||
|
||||
expect(result).toEqual({ ok: true, version: '2.2.1', versionSupported: true, error: null })
|
||||
expect(result).toEqual({ ok: true, version: '2.2.5', 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')}`)
|
||||
@@ -478,7 +478,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
username: 'alice',
|
||||
password: 'super-secret',
|
||||
})
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.1' }))
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.5' }))
|
||||
|
||||
const result = await registry.test({ serverId: server.id })
|
||||
|
||||
@@ -493,7 +493,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
baseUrl: 'https://studio.example.com',
|
||||
password: 'super-secret',
|
||||
})
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.1' }))
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.5' }))
|
||||
|
||||
const result = await registry.test({
|
||||
baseUrl: 'https://studio.example.com/opencode',
|
||||
@@ -513,7 +513,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
baseUrl: 'https://studio.example.com',
|
||||
password: 'super-secret',
|
||||
})
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.1' }))
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.5' }))
|
||||
|
||||
const result = await registry.test({
|
||||
baseUrl: 'https://relocated.example.com',
|
||||
@@ -533,7 +533,7 @@ describe('OpenCodeServerRegistry', () => {
|
||||
baseUrl: 'https://studio.example.com',
|
||||
password: 'super-secret',
|
||||
})
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.1' }))
|
||||
fetchFn.mockResolvedValueOnce(jsonResponse({ version: '2.2.5' }))
|
||||
|
||||
await registry.test({
|
||||
baseUrl: 'https://studio.example.com',
|
||||
|
||||
@@ -16,7 +16,7 @@ vi.mock('child_process', () => ({
|
||||
spawn: childProcessMock.spawn,
|
||||
}))
|
||||
|
||||
const SUPPORTED_VERSION = '2.2.1'
|
||||
const SUPPORTED_VERSION = '2.2.5'
|
||||
const OPENCODE_BIN_FIXTURE = '/fixture/opencode-2'
|
||||
const PATH_CANDIDATE = 'opencode'
|
||||
const ABSOLUTE_CANDIDATES = ['/usr/local/bin/opencode', '/opt/opencode/bin/opencode']
|
||||
|
||||
@@ -382,7 +382,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
mockInstallOpenCodeVersion.mockResolvedValue('/home/node/.opencode/bin/opencode')
|
||||
clearOpenCodeVersionCache()
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(JSON.stringify({
|
||||
versions: { '2.2.1': {} },
|
||||
versions: { '2.2.5': {} },
|
||||
time: {},
|
||||
}), { status: 200 })))
|
||||
forceProcessAttestation(true)
|
||||
@@ -913,7 +913,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
describe('successful upgrade scenarios', () => {
|
||||
it('should install the latest version and respond with success', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const req = new Request('http://localhost/opencode-upgrade', {
|
||||
@@ -926,13 +926,13 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
expect(json.success).toBe(true)
|
||||
expect(json.upgraded).toBe(true)
|
||||
expect(json.oldVersion).toBe('2.1.1')
|
||||
expect(json.newVersion).toBe('2.2.1')
|
||||
expect(json.message).toBe('OpenCode upgraded from v2.1.1 to v2.2.1 and restarted')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(json.newVersion).toBe('2.2.5')
|
||||
expect(json.message).toBe('OpenCode upgraded from v2.1.1 to v2.2.5 and restarted')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
|
||||
it('should not install when the latest version is not newer', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('2.2.1')
|
||||
mockGetVersion.mockReturnValueOnce('2.2.5')
|
||||
|
||||
const req = new Request('http://localhost/opencode-upgrade', {
|
||||
method: 'POST'
|
||||
@@ -950,7 +950,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
it('should replace an unsupported newer major with the latest supported release', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('3.0.0')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-upgrade', { method: 'POST' }))
|
||||
@@ -958,12 +958,12 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(json.upgraded).toBe(true)
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
|
||||
it('should restart directly after a successful upgrade', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const req = new Request('http://localhost/opencode-upgrade', {
|
||||
@@ -977,13 +977,13 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
it('allows upgrading while sandbox enforcement is active', async () => {
|
||||
mockIsSandboxEnforced.mockReturnValue(true)
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-upgrade', { method: 'POST' }))
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
expect(mockRestart).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1052,7 +1052,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
describe('version handling', () => {
|
||||
it('should install and restart when getVersion returns null', async () => {
|
||||
mockGetVersion.mockReturnValueOnce(null)
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const req = new Request('http://localhost/opencode-upgrade', {
|
||||
@@ -1065,8 +1065,8 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
expect(json.success).toBe(true)
|
||||
expect(json.upgraded).toBe(true)
|
||||
expect(json.oldVersion).toBe(null)
|
||||
expect(json.newVersion).toBe('2.2.1')
|
||||
expect(json.message).toBe('OpenCode v2.2.1 installed and restarted')
|
||||
expect(json.newVersion).toBe('2.2.5')
|
||||
expect(json.message).toBe('OpenCode v2.2.5 installed and restarted')
|
||||
expect(mockFetchVersion).toHaveBeenCalled()
|
||||
expect(mockClearStartupError).toHaveBeenCalled()
|
||||
expect(mockRestart).toHaveBeenCalledTimes(1)
|
||||
@@ -1088,7 +1088,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
expect(json.upgraded).toBe(false)
|
||||
expect(json.recovered).toBe(true)
|
||||
expect(json.error).toBe('Upgrade failed but server recovered')
|
||||
expect(json.details).toContain('did not result in version 2.2.1')
|
||||
expect(json.details).toContain('did not result in version 2.2.5')
|
||||
expect(mockRestart).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
@@ -1105,7 +1105,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
expect(json.upgraded).toBe(false)
|
||||
expect(json.recovered).toBe(true)
|
||||
expect(json.error).toBe('Upgrade failed but server recovered')
|
||||
expect(json.details).toContain('did not result in version 2.2.1')
|
||||
expect(json.details).toContain('did not result in version 2.2.5')
|
||||
expect(mockRestart).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -1115,12 +1115,12 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
describe('successful installation', () => {
|
||||
it('should install specific version successfully', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const req = new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
const res = await settingsApp.fetch(req)
|
||||
@@ -1128,8 +1128,8 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(json.success).toBe(true)
|
||||
expect(json.newVersion).toBe('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(json.newVersion).toBe('2.2.5')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
|
||||
it('does not report success when the requested version was not installed', async () => {
|
||||
@@ -1139,46 +1139,46 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}))
|
||||
const json = await res.json() as Record<string, unknown>
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
expect(json.success).toBe(false)
|
||||
expect(json.details).toContain('did not result in version 2.2.1')
|
||||
expect(json.details).toContain('did not result in version 2.2.5')
|
||||
expect(json.newVersion).toBe('2.1.1')
|
||||
})
|
||||
|
||||
it('allows installing any version while sandbox enforcement is active', async () => {
|
||||
mockIsSandboxEnforced.mockReturnValue(true)
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}))
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
|
||||
it('should install the bare version when the request carries a v prefix', async () => {
|
||||
mockGetVersion.mockReturnValueOnce('2.1.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.1')
|
||||
mockFetchVersion.mockResolvedValueOnce('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const req = new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: 'v2.2.1' }),
|
||||
body: JSON.stringify({ version: 'v2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
await settingsApp.fetch(req)
|
||||
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1191,7 +1191,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
const req = new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
const res = await settingsApp.fetch(req)
|
||||
@@ -1208,7 +1208,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
|
||||
const req = new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
const res = await settingsApp.fetch(req)
|
||||
@@ -1275,11 +1275,11 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
const json = await res.json() as Record<string, unknown>
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
expect(json.error).toBe('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.2.1 <3.0.0')
|
||||
expect(json.error).toBe('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0')
|
||||
expect(mockInstallOpenCodeVersion).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each(['2.2.0', '3.0.0'])('should reject %s outside the supported range before installing anything', async (version) => {
|
||||
it.each(['2.2.4', '3.0.0'])('should reject %s outside the supported range before installing anything', async (version) => {
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version }),
|
||||
@@ -1288,14 +1288,14 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
const json = await res.json() as Record<string, unknown>
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
expect(json.error).toBe(`OpenCode ${version} is not supported; OpenCode Manager requires OpenCode >=2.2.1 <3.0.0`)
|
||||
expect(json.error).toBe(`OpenCode ${version} is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0`)
|
||||
expect(mockInstallOpenCodeVersion).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should reject a prerelease version before installing anything', async () => {
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ version: '2.2.1-beta.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5-beta.1' }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}))
|
||||
|
||||
@@ -1332,7 +1332,7 @@ describe('Settings Routes - OpenCode Upgrade', () => {
|
||||
const res = await settingsApp.fetch(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
}))
|
||||
const json = await res.json() as Record<string, unknown>
|
||||
|
||||
@@ -2109,8 +2109,8 @@ describe('Settings Routes - versions, directory files, skills, MCP and maintenan
|
||||
fetchMock = vi.fn()
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
clearOpenCodeVersionCache()
|
||||
mockGetVersion.mockReturnValue('2.2.1')
|
||||
mockFetchVersion.mockResolvedValue('2.2.1')
|
||||
mockGetVersion.mockReturnValue('2.2.5')
|
||||
mockFetchVersion.mockResolvedValue('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockReset()
|
||||
mockInstallOpenCodeVersion.mockResolvedValue('/home/node/.opencode/bin/opencode')
|
||||
mockClearStartupError.mockReturnValue(undefined)
|
||||
@@ -2133,14 +2133,14 @@ describe('Settings Routes - versions, directory files, skills, MCP and maintenan
|
||||
versions: {
|
||||
'1.18.32': {},
|
||||
'2.1.1': {},
|
||||
'2.2.1': {},
|
||||
'2.2.2': {},
|
||||
'2.2.1-beta.1': {},
|
||||
'2.2.5': {},
|
||||
'2.2.6': {},
|
||||
'2.2.5-beta.1': {},
|
||||
'3.0.0': {},
|
||||
},
|
||||
time: {
|
||||
'2.2.1': '2026-01-02T00:00:00Z',
|
||||
'2.2.2': '2026-01-03T00:00:00Z',
|
||||
'2.2.5': '2026-01-02T00:00:00Z',
|
||||
'2.2.6': '2026-01-03T00:00:00Z',
|
||||
},
|
||||
}), { status: 200 }))
|
||||
|
||||
@@ -2148,16 +2148,16 @@ describe('Settings Routes - versions, directory files, skills, MCP and maintenan
|
||||
const json = await res.json() as { versions: Array<{ version: string; tag: string; name: string; publishedAt: string | null }>; currentVersion: string }
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(json.currentVersion).toBe('2.2.1')
|
||||
expect(json.currentVersion).toBe('2.2.5')
|
||||
expect(json.versions).toEqual([
|
||||
{ version: '2.2.2', tag: 'v2.2.2', name: 'v2.2.2', publishedAt: '2026-01-03T00:00:00Z' },
|
||||
{ version: '2.2.1', tag: 'v2.2.1', name: 'v2.2.1', publishedAt: '2026-01-02T00:00:00Z' },
|
||||
{ version: '2.2.6', tag: 'v2.2.6', name: 'v2.2.6', publishedAt: '2026-01-03T00:00:00Z' },
|
||||
{ version: '2.2.5', tag: 'v2.2.5', name: 'v2.2.5', publishedAt: '2026-01-02T00:00:00Z' },
|
||||
])
|
||||
expect(fetchMock).toHaveBeenCalledWith('https://registry.npmjs.org/@opencode/cli')
|
||||
})
|
||||
|
||||
it('serves repeated requests from the installer cache', async () => {
|
||||
fetchMock.mockImplementation(async () => new Response(JSON.stringify({ versions: { '2.2.1': {} }, time: {} }), { status: 200 }))
|
||||
fetchMock.mockImplementation(async () => new Response(JSON.stringify({ versions: { '2.2.5': {} }, time: {} }), { status: 200 }))
|
||||
|
||||
await app.request(new Request('http://localhost/opencode-versions'))
|
||||
const res = await app.request(new Request('http://localhost/opencode-versions'))
|
||||
@@ -2195,35 +2195,35 @@ describe('Settings Routes - versions, directory files, skills, MCP and maintenan
|
||||
describe('POST /opencode-install-version', () => {
|
||||
it('installs the requested version and restarts the server', async () => {
|
||||
mockGetVersion.mockReturnValue('2.1.1')
|
||||
mockFetchVersion.mockResolvedValue('2.2.1')
|
||||
mockFetchVersion.mockResolvedValue('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockResolvedValueOnce('/home/node/.opencode/bin/opencode')
|
||||
|
||||
const res = await app.request(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
}))
|
||||
const json = await res.json() as { success: boolean; message: string; oldVersion: string; newVersion: string }
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(json.success).toBe(true)
|
||||
expect(json.oldVersion).toBe('2.1.1')
|
||||
expect(json.newVersion).toBe('2.2.1')
|
||||
expect(json.message).toContain('changed from v2.1.1 to v2.2.1')
|
||||
expect(json.newVersion).toBe('2.2.5')
|
||||
expect(json.message).toContain('changed from v2.1.1 to v2.2.5')
|
||||
expect(supervisor.restart).toHaveBeenCalledTimes(1)
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.1')
|
||||
expect(mockInstallOpenCodeVersion).toHaveBeenCalledWith('2.2.5')
|
||||
})
|
||||
|
||||
it('returns 500 without restarting when the version install fails before the binary swap', async () => {
|
||||
mockGetVersion.mockReturnValue('2.1.1')
|
||||
mockFetchVersion.mockResolvedValue('2.2.1')
|
||||
mockFetchVersion.mockResolvedValue('2.2.5')
|
||||
mockInstallOpenCodeVersion.mockRejectedValueOnce(new Error('download failed'))
|
||||
supervisor.restart.mockResolvedValue({ healthy: false })
|
||||
|
||||
const res = await app.request(new Request('http://localhost/opencode-install-version', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ version: '2.2.1' }),
|
||||
body: JSON.stringify({ version: '2.2.5' }),
|
||||
}))
|
||||
const json = await res.json() as { recovered: boolean; newVersion: string }
|
||||
|
||||
|
||||
@@ -240,6 +240,7 @@ const runOpenCodeSection = (snippet: string, env: Record<string, string> = {}) =
|
||||
OCM_STUB_RUNUSER_EXEC: '1',
|
||||
HOME: homeDir,
|
||||
OPENCODE_BUNDLED_VERSION: '2.0.15',
|
||||
OPENCODE_MIN_VERSION: '2.0.15',
|
||||
...env,
|
||||
},
|
||||
})
|
||||
@@ -459,11 +460,11 @@ exit 1`)
|
||||
expect(curlLog()).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('treats every persisted binary as unsupported when the bundled version is unknown', () => {
|
||||
it('treats every persisted binary as unsupported when the minimum version is unknown', () => {
|
||||
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_BUNDLED_VERSION: '',
|
||||
OPENCODE_MIN_VERSION: '',
|
||||
})
|
||||
expect(res.status).toBe(0)
|
||||
expect(existsSync(homeBinPath())).toBe(false)
|
||||
|
||||
@@ -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.2.1')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
const installedPath = await installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const installedPath = await installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory))
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.1/opencode-linux-x64.tar.gz'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/opencode-linux-x64.tar.gz'])
|
||||
expect(statSync(installedPath).mode & 0o777).toBe(0o755)
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.1')
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.5')
|
||||
})
|
||||
|
||||
it('requests the musl asset for a musl linux target', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.1')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
await installOpenCodeVersion('2.2.1', {
|
||||
await installOpenCodeVersion('2.2.5', {
|
||||
fetch: fetchFn,
|
||||
homeDirectory,
|
||||
target: { platform: 'linux', arch: 'arm64', musl: true },
|
||||
})
|
||||
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.1/opencode-linux-arm64-musl.tar.gz'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/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.2.1')
|
||||
const archivePath = createDarwinArchive(workDirectory, '2.2.5')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
const installedPath = await installOpenCodeVersion('2.2.1', {
|
||||
const installedPath = await installOpenCodeVersion('2.2.5', {
|
||||
fetch: fetchFn,
|
||||
homeDirectory,
|
||||
target: { platform: 'darwin', arch: 'arm64', musl: false },
|
||||
})
|
||||
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.1/opencode-darwin-arm64.zip'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/opencode-darwin-arm64.zip'])
|
||||
expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory))
|
||||
expect(statSync(installedPath).mode & 0o777).toBe(0o755)
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.1')
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.5')
|
||||
})
|
||||
|
||||
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.2.1 <3.0.0')
|
||||
.rejects.toThrow('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0')
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
it.each(['2.2.0', '3.0.0', '2.2.1-beta.1', '2.2.1; rm -rf /'])(
|
||||
it.each(['2.2.4', '3.0.0', '2.2.5-beta.1', '2.2.5; 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\.2\.1 <3\.0\.0/)
|
||||
.rejects.toThrow(/requires OpenCode >=2\.2\.5 <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.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
await expect(installOpenCodeVersion('2.2.5', { 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.2.2')
|
||||
const archivePath = createArchive(workDirectory, '2.2.6')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
await expect(installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/2\.2\.1/)
|
||||
await expect(installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/2\.2\.5/)
|
||||
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.2.1')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
await installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
await installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.2.1')
|
||||
expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.2.5')
|
||||
})
|
||||
|
||||
it('cleans up its staging directory after a successful install', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.1')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
const before = countStagingDirectories()
|
||||
await installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
await installOpenCodeVersion('2.2.5', { 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.2.1': {},
|
||||
'2.2.2': {},
|
||||
'2.2.1-beta.1': {},
|
||||
'2.2.5': {},
|
||||
'2.2.6': {},
|
||||
'2.2.5-beta.1': {},
|
||||
'3.0.0': {},
|
||||
'not-a-version': {},
|
||||
},
|
||||
time: {
|
||||
'2.2.1': '2026-02-01T00:00:00.000Z',
|
||||
'2.2.2': '2026-03-01T00:00:00.000Z',
|
||||
'2.2.5': '2026-02-01T00:00:00.000Z',
|
||||
'2.2.6': '2026-03-01T00:00:00.000Z',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -262,8 +262,8 @@ describe('listOpenCodeVersions', () => {
|
||||
const versions = await listOpenCodeVersions({ fetch: fetchFn })
|
||||
|
||||
expect(versions).toEqual([
|
||||
{ version: '2.2.2', publishedAt: '2026-03-01T00:00:00.000Z' },
|
||||
{ version: '2.2.1', publishedAt: '2026-02-01T00:00:00.000Z' },
|
||||
{ version: '2.2.6', publishedAt: '2026-03-01T00:00:00.000Z' },
|
||||
{ version: '2.2.5', publishedAt: '2026-02-01T00:00:00.000Z' },
|
||||
])
|
||||
expect(calls).toEqual(['https://registry.npmjs.org/@opencode/cli'])
|
||||
})
|
||||
@@ -331,7 +331,7 @@ describe('OpenCodeInstallError swap signalling', () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const { fetchFn } = createFetch(null, 404)
|
||||
|
||||
const promise = installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const promise = installOpenCodeVersion('2.2.5', { 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.2.1')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
const promise = installOpenCodeVersion('2.2.1', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const promise = installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
await expect(promise).rejects.toBeInstanceOf(OpenCodeInstallError)
|
||||
await expect(promise).rejects.toMatchObject({ swapStarted: true })
|
||||
|
||||
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach, afterEach, beforeAll } from 'vite
|
||||
const createOpenCodeClientMock = vi.hoisted(() => vi.fn(() => ({
|
||||
api: {
|
||||
server: {
|
||||
info: vi.fn().mockResolvedValue({ version: '2.2.1', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }),
|
||||
info: vi.fn().mockResolvedValue({ version: '2.2.5', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }),
|
||||
},
|
||||
},
|
||||
forwardRaw: vi.fn(),
|
||||
@@ -354,7 +354,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
setOpenCodeEnv({ host: '0.0.0.0', password: 'envpassword123' })
|
||||
@@ -382,7 +382,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
setOpenCodeEnv({ host: '0.0.0.0', password: '' })
|
||||
@@ -420,7 +420,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -539,7 +539,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const savedEnv = snapshotMicrosandboxEnv()
|
||||
@@ -782,7 +782,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
let capturedSignal: AbortSignal | undefined
|
||||
const info = vi.fn(async (options: { signal?: AbortSignal }) => {
|
||||
capturedSignal = options.signal
|
||||
return { version: '2.2.1', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }
|
||||
return { version: '2.2.5', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }
|
||||
})
|
||||
createOpenCodeClientMock.mockImplementationOnce(() => ({
|
||||
api: { server: { info } },
|
||||
@@ -812,7 +812,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
capturedSignal = options.signal
|
||||
queueMicrotask(() => emitExit(1, null))
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve({ version: '2.2.1', pid: 1234, urls: [], paths: { tmp: '/tmp' } }), 0)
|
||||
setTimeout(() => resolve({ version: '2.2.5', pid: 1234, urls: [], paths: { tmp: '/tmp' } }), 0)
|
||||
})
|
||||
})
|
||||
createOpenCodeClientMock.mockImplementationOnce(() => ({
|
||||
@@ -861,7 +861,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -949,7 +949,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -1035,7 +1035,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
manager.setDatabase(createPasswordDb(null))
|
||||
@@ -1148,7 +1148,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -1198,7 +1198,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
if (cmd.includes('lsof')) {
|
||||
return spawnMock.mock.calls.length > 0 ? '1234\n' : '9999\n'
|
||||
}
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -1945,7 +1945,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
if (cmd.includes('lsof')) {
|
||||
return spawnMock.mock.calls.length > 0 ? '1234\n' : '9999\n'
|
||||
}
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
readFileSyncMock.mockReturnValue(procStatStringWithGroup(9999, '42'))
|
||||
@@ -2002,7 +2002,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
readdirSyncMock.mockReturnValue(['10001'])
|
||||
@@ -2081,7 +2081,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
readdirSyncMock.mockReturnValue(['10001'])
|
||||
@@ -2144,7 +2144,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
readFileSyncMock.mockImplementation((filePath: string) => {
|
||||
@@ -2200,7 +2200,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return '9999\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
readFileSyncMock.mockReturnValue(procStatStringWithGroup(9999, '42'))
|
||||
@@ -2242,7 +2242,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return '9998\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
killSpy.mockImplementation(((pid: number, signal?: number | string) => {
|
||||
@@ -2279,7 +2279,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return '9997\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
killSpy.mockImplementation(((pid: number, signal?: number | string) => {
|
||||
@@ -2311,7 +2311,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '8888\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
killSpy.mockImplementation(((pid: number, signal?: number | string) => {
|
||||
@@ -2986,7 +2986,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
installManagedPluginsMock.mockRejectedValueOnce(new Error('readonly filesystem'))
|
||||
@@ -3018,7 +3018,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -3049,7 +3049,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -3077,7 +3077,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
restoreQuarantinedOpenCodePluginsMock.mockRejectedValueOnce(new Error('readonly filesystem'))
|
||||
@@ -3108,7 +3108,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
installManagedPluginsMock.mockRejectedValueOnce(new Error('readonly filesystem'))
|
||||
@@ -3140,7 +3140,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('lsof')) return spawnMock.mock.calls.length > 0 ? '1234\n' : ''
|
||||
if (cmd.includes('opencode --version')) return '2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return '2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -3176,7 +3176,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
await expect(manager.start()).rejects.toThrow('OpenCode 1.18.32 is not supported')
|
||||
|
||||
expect(spawnMock).not.toHaveBeenCalled()
|
||||
expect(manager.getLastStartupError()).toContain('requires OpenCode >=2.2.1 <3.0.0')
|
||||
expect(manager.getLastStartupError()).toContain('requires OpenCode >=2.2.5 <3.0.0')
|
||||
expect(manager.isLastStartupErrorNonRecoverable()).toBe(true)
|
||||
})
|
||||
|
||||
@@ -3185,7 +3185,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
isEnabled: () => false,
|
||||
}))
|
||||
execSyncMock.mockImplementation((cmd: string) => {
|
||||
if (cmd.includes('opencode --version')) return 'opencode v2.2.1\n'
|
||||
if (cmd.includes('opencode --version')) return 'opencode v2.2.5\n'
|
||||
throw new Error('not found')
|
||||
})
|
||||
const { OpenCodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
@@ -3195,7 +3195,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
await manager.start()
|
||||
|
||||
expect(spawnMock).toHaveBeenCalled()
|
||||
expect(manager.getVersion()).toBe('2.2.1')
|
||||
expect(manager.getVersion()).toBe('2.2.5')
|
||||
expect(manager.isVersionSupported()).toBe(true)
|
||||
})
|
||||
|
||||
@@ -3216,7 +3216,7 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
marked = true
|
||||
manager.markRestartPending()
|
||||
}
|
||||
return { version: '2.2.1', pid: 1234, urls: [], paths: { tmp: '/tmp' } }
|
||||
return { version: '2.2.5', pid: 1234, urls: [], paths: { tmp: '/tmp' } }
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -3438,7 +3438,7 @@ describe('ConfigReloadError', () => {
|
||||
})
|
||||
|
||||
describe('OpenCodeServerManager - checkHealth', () => {
|
||||
const serverInfo = { version: '2.2.1', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }
|
||||
const serverInfo = { version: '2.2.5', pid: 1234, urls: ['http://127.0.0.1:5551'], paths: { tmp: '/tmp' } }
|
||||
|
||||
it('probes GET /api/info through the API client and returns true for a ServerInfo response', async () => {
|
||||
const { opencodeServerManager } = await import('../../src/services/opencode-single-server')
|
||||
|
||||
@@ -2,6 +2,7 @@ import { readdirSync, readFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
OPENCODE_MIN_VERSION,
|
||||
OPENCODE_PINNED_VERSION,
|
||||
OPENCODE_SERVER_USERNAME,
|
||||
OPENCODE_SUPPORTED_VERSION_RANGE,
|
||||
@@ -49,9 +50,11 @@ function createFetchSpy() {
|
||||
|
||||
describe('OpenCode v2 contract', () => {
|
||||
describe('version policy', () => {
|
||||
it('pins the client version, derives the floor from it and fixes the V2 server username', () => {
|
||||
expect(OPENCODE_PINNED_VERSION).toBe('2.2.1')
|
||||
expect(OPENCODE_SUPPORTED_VERSION_RANGE).toBe('>=2.2.1 <3.0.0')
|
||||
it('pins the built-against version, keeps a separate supported floor and fixes the V2 server username', () => {
|
||||
expect(OPENCODE_PINNED_VERSION).toBe('2.2.5')
|
||||
expect(OPENCODE_MIN_VERSION).toBe('2.2.5')
|
||||
expect(compareOpenCodeVersions(OPENCODE_PINNED_VERSION, OPENCODE_MIN_VERSION)).toBeGreaterThanOrEqual(0)
|
||||
expect(OPENCODE_SUPPORTED_VERSION_RANGE).toBe('>=2.2.5 <3.0.0')
|
||||
expect(OPENCODE_SERVER_USERNAME).toBe('opencode')
|
||||
})
|
||||
|
||||
@@ -61,48 +64,49 @@ describe('OpenCode v2 contract', () => {
|
||||
expect(isSupportedOpenCodeVersion('2.0.15')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.1.0')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.1.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.0')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.2')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.4')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.6')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.3.0')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('v2.2.1')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion(' v2.2.1 ')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('v2.2.5')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion(' v2.2.5 ')).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.2.1-alpha.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1-alpha')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1-rc.1+build.5')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1-0')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5-alpha.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5-alpha')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5-rc.1+build.5')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5-0')).toBe(false)
|
||||
})
|
||||
|
||||
it('accepts prereleases of higher numeric cores within the pinned major', () => {
|
||||
expect(isSupportedOpenCodeVersion('2.3.0-beta.1')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.2-rc.2')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.6-rc.2')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('3.0.0-beta.1')).toBe(false)
|
||||
})
|
||||
|
||||
it('ignores build metadata for precedence', () => {
|
||||
expect(isSupportedOpenCodeVersion('2.2.1+build')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1+2.0.0')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5+build')).toBe(true)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5+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.2.1.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('02.2.1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.1-alpha..1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('2.2.5-alpha..1')).toBe(false)
|
||||
expect(isSupportedOpenCodeVersion('')).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.1 <3.0.0',
|
||||
'OpenCode 3.0.0 is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0',
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -144,25 +148,34 @@ describe('OpenCode v2 contract', () => {
|
||||
})
|
||||
|
||||
describe('pinned version sources', () => {
|
||||
it('keeps the Dockerfile OPENCODE_VERSION default in sync with the pin', () => {
|
||||
it('keeps the Dockerfile OPENCODE_VERSION and OPENCODE_MIN_VERSION defaults in sync with the pin and floor', () => {
|
||||
const dockerfile = readFileSync(join(REPO_ROOT, 'Dockerfile'), 'utf8')
|
||||
expect(dockerfile).toMatch(new RegExp(`^ARG OPENCODE_VERSION=${OPENCODE_PINNED_VERSION.replace(/\./g, '\\.')}$`, 'm'))
|
||||
expect(dockerfile).toMatch(new RegExp(`^ARG OPENCODE_MIN_VERSION=${OPENCODE_MIN_VERSION.replace(/\./g, '\\.')}$`, 'm'))
|
||||
expect(dockerfile).toMatch(/^ENV OPENCODE_BUNDLED_VERSION=\$\{OPENCODE_VERSION\}$/m)
|
||||
expect(dockerfile).toMatch(/^ENV OPENCODE_MIN_VERSION=\$\{OPENCODE_MIN_VERSION\}$/m)
|
||||
})
|
||||
|
||||
it('keeps the shared SDK dependency in sync with the pin', () => {
|
||||
it('resolves every @opencode package from the workspace catalog at the pin', () => {
|
||||
const workspace = readFileSync(join(REPO_ROOT, 'pnpm-workspace.yaml'), 'utf8')
|
||||
const catalogVersion = (name: string) =>
|
||||
workspace.match(new RegExp(`^\\s+'${name.replace(/[/.]/g, '\\$&')}':\\s*(\\S+)$`, 'm'))?.[1]
|
||||
for (const name of ['@opencode/client', '@opencode/schema', '@opencode/plugin', '@opencode/theme']) {
|
||||
expect(catalogVersion(name)).toBe(OPENCODE_PINNED_VERSION)
|
||||
}
|
||||
const manifest = JSON.parse(
|
||||
readFileSync(join(REPO_ROOT, 'shared', 'package.json'), 'utf8'),
|
||||
) as PackageManifest
|
||||
expect(manifest.dependencies['@opencode/client']).toBe(OPENCODE_PINNED_VERSION)
|
||||
expect(manifest.dependencies['@opencode/client']).toBe('catalog:')
|
||||
expect(manifest.dependencies['@opencode/schema']).toBe('catalog:')
|
||||
})
|
||||
|
||||
it('makes the shell scripts derive the pin from the Dockerfile or the bundled version instead of hardcoding it', () => {
|
||||
it('makes the shell scripts derive the floor from the Dockerfile or the environment instead of hardcoding it', () => {
|
||||
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_BUNDLED_VERSION:-}"')
|
||||
expect(setupDev).toContain("sed -n 's/^ARG OPENCODE_VERSION=//p' \"$REPO_ROOT/Dockerfile\"")
|
||||
expect(entrypoint).toContain('OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_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.])/)
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ function TestResultSummary({ result }: { result: OpenCodeServerTestResult }) {
|
||||
{result.versionSupported ? (
|
||||
<Badge variant="secondary">Supported</Badge>
|
||||
) : (
|
||||
<Badge variant="destructive">Unsupported version</Badge>
|
||||
<Badge variant="outline">Different version: some features may not work</Badge>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ function ServerTestResult({ result }: { result: OpenCodeServerTestResult }) {
|
||||
{result.versionSupported ? (
|
||||
<Badge variant="secondary">Supported</Badge>
|
||||
) : (
|
||||
<Badge variant="destructive">Unsupported version</Badge>
|
||||
<Badge variant="outline">Different version: some features may not work</Badge>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
+10
-6
@@ -10,11 +10,12 @@ to the local working tree.
|
||||
|
||||
| ocm | OpenCode Manager | Local OpenCode |
|
||||
|---|---|---|
|
||||
| 0.6.x | >= 0.19.0 | >= 2.2.3, < 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 |
|
||||
|
||||
ocm 0.5.x, 0.4.x and 0.3.x attach through the repo-scoped Manager proxy
|
||||
ocm 0.6.x, 0.5.x, 0.4.x and 0.3.x attach through the repo-scoped Manager proxy
|
||||
(`/api/opencode-proxy/repos/:repoId`), load the plugin from the OpenCode 2
|
||||
`cli.json` `plugins` list, and move sessions with OpenCode 2 session
|
||||
export/import. Older Managers lack that route; `ocm` then fails with
|
||||
@@ -24,10 +25,13 @@ Use ocm 0.2.x with OpenCode Manager < 0.19.0 and OpenCode 1.x, installed pinned
|
||||
`@opencode-manager/ocm-cli@0.2`. ocm is published together with each OpenCode Manager
|
||||
release.
|
||||
|
||||
From ocm 0.5.0, the TUI plugin is built against `@opencode/plugin` 2.2.x and
|
||||
OpenTUI 0.7, so it 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 OpenTUI
|
||||
0.7 peers. Stay on ocm 0.4.x with a local OpenCode older than 2.2.0.
|
||||
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
|
||||
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
|
||||
OpenCode older than 2.2.0.
|
||||
|
||||
ocm 0.5.0 removes `/ocm-goal`; session goals use OpenCode's built-in `/goal`
|
||||
command, and OpenCode Manager no longer serves `/api/internal/session-goals`.
|
||||
@@ -320,7 +324,7 @@ global installs); the plugin surface is TUI-only.
|
||||
## Requirements
|
||||
|
||||
- macOS or Linux (Windows is unsupported)
|
||||
- OpenCode >= 2.2.0 (same major, 2.x) available on `PATH` for the TUI plugin
|
||||
- OpenCode >= 2.2.3 (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`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode-manager/ocm-cli",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"description": "OpenCode Manager CLI: attach a local OpenCode TUI to a Manager-hosted repo.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -18,9 +18,9 @@
|
||||
}
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opencode/theme": ">=2.2.1 <3.0.0",
|
||||
"@opentui/core": ">=0.7.0 <0.8.0",
|
||||
"@opentui/solid": ">=0.7.0 <0.8.0",
|
||||
"@opencode/theme": ">=2.2.5 <3.0.0",
|
||||
"@opentui/core": ">=0.8.0 <0.9.0",
|
||||
"@opentui/solid": ">=0.8.0 <0.9.0",
|
||||
"solid-js": ">=1.9.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -58,16 +58,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@opencode/plugin": "2.2.1",
|
||||
"@opencode/theme": "2.2.1",
|
||||
"@opencode-manager/shared": "workspace:*",
|
||||
"@opentui/core": "0.7.0",
|
||||
"@opentui/solid": "0.7.0",
|
||||
"@opencode/plugin": "catalog:",
|
||||
"@opencode/theme": "catalog:",
|
||||
"@opentui/core": "catalog:",
|
||||
"@opentui/solid": "catalog:",
|
||||
"@types/bun": "^1.3.14",
|
||||
"@types/node": "^22.0.0",
|
||||
"eslint": "^9.39.1",
|
||||
"jsonc-parser": "^3.3.1",
|
||||
"solid-js": "1.9.12",
|
||||
"solid-js": "catalog:",
|
||||
"typescript": "^5.5.0",
|
||||
"typescript-eslint": "^8.45.0",
|
||||
"uqr": "^0.1.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { parseSemver } from '@opencode-manager/shared/utils'
|
||||
import { compareSemver, parseSemver } from '@opencode-manager/shared/utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
interface PackageManifest {
|
||||
@@ -20,21 +20,40 @@ function readManifest(path: string): PackageManifest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the minor-line peer range for a plugin's exact dependency pin.
|
||||
* Reads the version of a dependency installed in ocm-cli's node_modules.
|
||||
*/
|
||||
function installedVersion(name: string): string {
|
||||
return readManifest(join(__dirname, '..', 'node_modules', name, 'package.json')).version
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the minor-line peer range for an exact dependency version.
|
||||
*
|
||||
* A `0.x.y` pin is constrained to its minor line; a pin at major `1` or above
|
||||
* A `0.x.y` version is constrained to its minor line; a version at major `1` or above
|
||||
* is constrained to its major line.
|
||||
*/
|
||||
function deriveMinorLineRange(pin: string): string {
|
||||
const parsed = parseSemver(pin)
|
||||
function deriveMinorLineRange(version: string): string {
|
||||
const parsed = parseSemver(version)
|
||||
if (!parsed || parsed.prerelease.length > 0) {
|
||||
throw new Error(`Cannot derive a peer range from pin "${pin}"`)
|
||||
throw new Error(`Cannot derive a peer range from version "${version}"`)
|
||||
}
|
||||
const { major, minor } = parsed
|
||||
if (major === 0) {
|
||||
return `>=0.${minor}.0 <0.${minor + 1}.0`
|
||||
}
|
||||
return `>=${pin} <${major + 1}.0.0`
|
||||
return `>=${version} <${major + 1}.0.0`
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that an installed version satisfies a plugin peer declaration,
|
||||
* accepting both an exact peer pin and an open `>=` floor.
|
||||
*/
|
||||
function expectVersionSatisfiesPeer(version: string, peer: string): void {
|
||||
if (peer.startsWith('>=')) {
|
||||
expect(compareSemver(version, peer.slice(2).trim())).toBeGreaterThanOrEqual(0)
|
||||
return
|
||||
}
|
||||
expect(version).toBe(peer)
|
||||
}
|
||||
|
||||
const ocmManifest = readManifest(join(__dirname, '..', 'package.json'))
|
||||
@@ -44,15 +63,16 @@ const pluginManifest = readManifest(
|
||||
|
||||
describe('ocm-cli package compatibility with the installed @opencode/plugin', () => {
|
||||
for (const name of PINNED_PACKAGES) {
|
||||
it(`${name} matches the plugin peer pin`, () => {
|
||||
const pluginPin = pluginManifest.peerDependencies[name]
|
||||
expect(ocmManifest.devDependencies[name]).toBe(pluginPin)
|
||||
expect(ocmManifest.peerDependencies[name]).toBe(deriveMinorLineRange(pluginPin))
|
||||
it(`${name} satisfies the plugin peer and derives the published peer range`, () => {
|
||||
const version = installedVersion(name)
|
||||
expectVersionSatisfiesPeer(version, pluginManifest.peerDependencies[name]!)
|
||||
expect(ocmManifest.devDependencies[name]).toBe('catalog:')
|
||||
expect(ocmManifest.peerDependencies[name]).toBe(deriveMinorLineRange(version))
|
||||
expect(ocmManifest.peerDependenciesMeta[name]?.optional).toBe(true)
|
||||
})
|
||||
}
|
||||
|
||||
it('@opencode/plugin devDependency matches the installed plugin version', () => {
|
||||
expect(ocmManifest.devDependencies['@opencode/plugin']).toBe(pluginManifest.version)
|
||||
it('resolves @opencode/plugin from the workspace catalog', () => {
|
||||
expect(ocmManifest.devDependencies['@opencode/plugin']).toBe('catalog:')
|
||||
})
|
||||
})
|
||||
Generated
+332
-366
File diff suppressed because it is too large.
Load diff
@@ -5,6 +5,16 @@ packages:
|
||||
- ocm-cli
|
||||
- '!workspace/**'
|
||||
|
||||
catalog:
|
||||
'@opencode/client': 2.2.5
|
||||
'@opencode/plugin': 2.2.5
|
||||
'@opencode/schema': 2.2.5
|
||||
'@opencode/theme': 2.2.5
|
||||
'@opentui/core': 0.8.2
|
||||
'@opentui/solid': 0.8.2
|
||||
effect: 4.0.6
|
||||
solid-js: 1.9.18
|
||||
|
||||
onlyBuiltDependencies:
|
||||
- better-sqlite3
|
||||
- esbuild
|
||||
|
||||
@@ -60,7 +60,7 @@ ensure_auth_secret() {
|
||||
export AUTH_SECRET
|
||||
}
|
||||
|
||||
OPENCODE_SUPPORTED_FLOOR="${OPENCODE_BUNDLED_VERSION:-}"
|
||||
OPENCODE_SUPPORTED_FLOOR="${OPENCODE_MIN_VERSION:-}"
|
||||
|
||||
read_opencode_version() {
|
||||
local binary output
|
||||
@@ -93,7 +93,7 @@ reconcile_persisted_opencode() {
|
||||
return 0
|
||||
fi
|
||||
if ! is_supported_opencode_version "$persisted_version"; then
|
||||
echo "Persisted OpenCode $persisted_version is outside the supported range $(supported_opencode_range); removing it so the bundled OpenCode $OPENCODE_SUPPORTED_FLOOR binary is used"
|
||||
echo "Persisted OpenCode $persisted_version is outside the supported range $(supported_opencode_range); removing it so the bundled OpenCode ${OPENCODE_BUNDLED_VERSION:-} binary is used"
|
||||
rm -f "$persisted_path"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -38,7 +38,7 @@ fi
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "$REPO_ROOT/scripts/lib/opencode-release.sh"
|
||||
OPENCODE_SUPPORTED_FLOOR="$(sed -n 's/^ARG OPENCODE_VERSION=//p' "$REPO_ROOT/Dockerfile" | head -1)"
|
||||
OPENCODE_SUPPORTED_FLOOR="$(sed -n 's/^ARG OPENCODE_MIN_VERSION=//p' "$REPO_ROOT/Dockerfile" | head -1)"
|
||||
OPENCODE_VERSION_OUTPUT="$(opencode --version 2>&1)" || OPENCODE_VERSION_OUTPUT=""
|
||||
OPENCODE_VERSION="$(parse_opencode_version_output "$OPENCODE_VERSION_OUTPUT")"
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode-manager/shared",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "Shared schemas, types, OpenCode helpers and Manager API contracts for OpenCode Manager clients.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -34,9 +34,9 @@
|
||||
"./themes": "./src/themes/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opencode/client": "2.2.1",
|
||||
"@opencode/schema": "2.2.1",
|
||||
"effect": "4.0.1",
|
||||
"@opencode/client": "catalog:",
|
||||
"@opencode/schema": "catalog:",
|
||||
"effect": "catalog:",
|
||||
"jsonc-parser": "^3.3.1",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
|
||||
@@ -136,6 +136,7 @@ export type {
|
||||
} from './pairing'
|
||||
|
||||
export {
|
||||
OPENCODE_MIN_VERSION,
|
||||
OPENCODE_PINNED_VERSION,
|
||||
OPENCODE_SUPPORTED_VERSION_RANGE,
|
||||
buildOpenCodeReleaseAsset,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { compareParsedSemver, compareSemver, normalizeSemver, parseSemver, type Semver } from '../utils/semver'
|
||||
|
||||
export const OPENCODE_PINNED_VERSION = '2.2.1'
|
||||
/** The OpenCode release Manager is built against and bundles; matches the `@opencode/*` pnpm catalog entries. */
|
||||
export const OPENCODE_PINNED_VERSION = '2.2.5'
|
||||
|
||||
/** The oldest OpenCode release Manager supports; any later release of the same major is accepted. */
|
||||
export const OPENCODE_MIN_VERSION = '2.2.5'
|
||||
|
||||
const OPENCODE_RELEASE_BASE_URL = 'https://opencode.ai/files/bin'
|
||||
|
||||
@@ -47,20 +51,20 @@ export function compareOpenCodeVersions(left: string, right: string): number {
|
||||
return compareSemver(left, right)
|
||||
}
|
||||
|
||||
function parsePinnedOpenCodeVersion(): OpenCodeVersion {
|
||||
const pinned = parseOpenCodeVersion(OPENCODE_PINNED_VERSION)
|
||||
if (!pinned) throw new Error(`OPENCODE_PINNED_VERSION is not a valid version: ${OPENCODE_PINNED_VERSION}`)
|
||||
return pinned
|
||||
function parseMinOpenCodeVersion(): OpenCodeVersion {
|
||||
const min = parseOpenCodeVersion(OPENCODE_MIN_VERSION)
|
||||
if (!min) throw new Error(`OPENCODE_MIN_VERSION is not a valid version: ${OPENCODE_MIN_VERSION}`)
|
||||
return min
|
||||
}
|
||||
|
||||
const OPENCODE_PINNED = parsePinnedOpenCodeVersion()
|
||||
const OPENCODE_MIN = parseMinOpenCodeVersion()
|
||||
|
||||
export const OPENCODE_SUPPORTED_VERSION_RANGE = `>=${OPENCODE_PINNED_VERSION} <${OPENCODE_PINNED.major + 1}.0.0`
|
||||
export const OPENCODE_SUPPORTED_VERSION_RANGE = `>=${OPENCODE_MIN_VERSION} <${OPENCODE_MIN.major + 1}.0.0`
|
||||
|
||||
export function isSupportedOpenCodeVersion(version: string): boolean {
|
||||
const parsed = parseOpenCodeVersion(version)
|
||||
if (!parsed) return false
|
||||
return parsed.major === OPENCODE_PINNED.major && compareParsedSemver(parsed, OPENCODE_PINNED) >= 0
|
||||
return parsed.major === OPENCODE_MIN.major && compareParsedSemver(parsed, OPENCODE_MIN) >= 0
|
||||
}
|
||||
|
||||
export function describeUnsupportedOpenCodeVersion(version: string): string {
|
||||
|
||||
Reference in new issue
Block a user