chore(opencode): move the typed OpenCode SDK to the 2.1.2 pin

The runtime pin moved to 2.1.2 while @opencode/client stayed at 2.0.15, so
the shared typed contract no longer matched the server.

- @opencode/client and @opencode/plugin move to 2.1.2
- session projection follows the 2.1 event shape (native replaces
  providerState and state, compaction drops recent)
- worktree error stubs carry the _tag discriminator
- the contract test fails when the SDK version drifts from the pin
This commit is contained in:
Chris Scott committed 2026-10-23 15:45:36 -04:00
1 parent 0c4c024dcc
commit 20017d2f7d
8 files changed
+294 -354

No files matched your search

+10 -2
View File
@@ -424,7 +424,11 @@ describe('DELETE /api/repos/:id/workspaces', () => {
const client = createStubOpenCodeClient()
client.api.worktree.list = mock(async () => ([{ directory: worktreeDir, strategy: 'git' }])) as any
client.api.worktree.remove = mock(async () => {
throw Object.assign(new Error('cannot remove'), { name: 'WorktreeError', data: { message: 'cannot remove' } })
throw Object.assign(new Error('cannot remove'), {
_tag: 'WorktreeError',
name: 'WorktreeError',
data: { message: 'cannot remove' },
})
}) as any
const app = createTestApp(db, client)
@@ -519,7 +523,11 @@ describe('POST /api/repos/:id/workspaces', () => {
createRepo(db, { localPath: 'repo-a', defaultBranch: 'main', cloneStatus: 'ready', clonedAt: Date.now(), isLocal: true })
const client = createStubOpenCodeClient()
client.api.worktree.create = mock(async () => {
throw Object.assign(new Error('cannot create'), { name: 'WorktreeError', data: { message: 'cannot create' } })
throw Object.assign(new Error('cannot create'), {
_tag: 'WorktreeError',
name: 'WorktreeError',
data: { message: 'cannot create' },
})
}) as any
const app = createTestApp(db, client)
@@ -26,6 +26,10 @@ interface CapturedRequest {
headers: Record<string, string>
}
interface PackageManifest {
dependencies: Record<string, string>
}
function createFetchSpy() {
const calls: CapturedRequest[] = []
const fetchSpy = (async (input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => {
@@ -145,6 +149,13 @@ describe('OpenCode v2 contract', () => {
expect(dockerfile).toMatch(/^ENV OPENCODE_BUNDLED_VERSION=\$\{OPENCODE_VERSION\}$/m)
})
it('keeps the shared SDK dependency in sync with the pin', () => {
const manifest = JSON.parse(
readFileSync(join(REPO_ROOT, 'shared', 'package.json'), 'utf8'),
) as PackageManifest
expect(manifest.dependencies['@opencode/client']).toBe(OPENCODE_PINNED_VERSION)
})
it('makes the shell scripts derive the pin from the Dockerfile or the bundled version 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')