mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
* feat(opencode): migrate OpenCode Manager to OpenCode 2 Port the backend lifecycle, generated plugins, event aggregation, schedules, worktrees, provider credentials, MCP, config handling, the frontend chat model, and the ocm CLI to OpenCode 2. Adopt @opencode/client 2.0.15 as the single typed V2 API contract, require OpenCode 2.0.0 or newer (pinned 2.0.15), and delete every V1-only code path. * refactor(opencode): reload config in place and drop v1 compatibility shims Route config/skill/AGENTS.md changes through the OpenCode location reload API instead of a full server restart, stop auto-resuming interrupted sessions, remove the restart coordinator and v1 MCP/version shims, and pin support to OpenCode >=2.0.15 <3.0.0. Adds integration-ready retries, service-mode launch, ocm-cli repo proxy, and new frontend form/MCP helpers. * refactor(opencode): consolidate v2 migration helpers and harden install, proxy, and session flows - extract shared semver and model-ref utilities, reuse across version checks - share the OpenCode release download script across Docker, entrypoint, dev setup - unify install/upgrade failure recovery and guard externally managed OPENCODE_BIN - scope the repo proxy location rewrite and surface ocm proxy errors - rework frontend session projection, permission lookup, and cache invalidation * fix(schedules): reject unavailable agents before creating a session * feat(opencode): add ocm install, schedule agent fallback, and session move guards
76 lines
3.0 KiB
TypeScript
76 lines
3.0 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { BLOCKED_SERVER_ENV_KEYS, DEFAULT_USER_PREFERENCES, UserPreferencesSchema } from '@opencode-manager/shared/schemas'
|
|
|
|
describe('settings schema - BLOCKED_SERVER_ENV_KEYS', () => {
|
|
it('blocks the OpenCode config source keys so the manager keeps a single on-disk config store', () => {
|
|
const blocked = new Set<string>(BLOCKED_SERVER_ENV_KEYS)
|
|
expect(blocked.has('OPENCODE_CONFIG')).toBe(true)
|
|
expect(blocked.has('OPENCODE_CONFIG_DIR')).toBe(true)
|
|
expect(blocked.has('OPENCODE_CONFIG_CONTENT')).toBe(true)
|
|
})
|
|
|
|
it('does not block auth-content or test env keys', () => {
|
|
const blocked = new Set<string>(BLOCKED_SERVER_ENV_KEYS)
|
|
expect(blocked.has('OPENCODE_AUTH_CONTENT')).toBe(false)
|
|
expect(blocked.has('OPENCODE_TEST_HOME')).toBe(false)
|
|
expect(blocked.has('OPENCODE_TEST_MANAGED_CONFIG_DIR')).toBe(false)
|
|
expect(blocked.has('SHELL')).toBe(false)
|
|
expect(blocked.has('BASH_ENV')).toBe(false)
|
|
expect(blocked.has('ENV')).toBe(false)
|
|
})
|
|
|
|
it('still blocks manager-owned password and XDG keys', () => {
|
|
const blocked = new Set<string>(BLOCKED_SERVER_ENV_KEYS)
|
|
expect(blocked.has('OPENCODE_SERVER_PASSWORD')).toBe(true)
|
|
expect(blocked.has('XDG_DATA_HOME')).toBe(true)
|
|
expect(blocked.has('XDG_STATE_HOME')).toBe(true)
|
|
expect(blocked.has('XDG_CONFIG_HOME')).toBe(true)
|
|
expect(blocked.has('TMPDIR')).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('settings schema - disabledDefaultServerEnvVars tolerance', () => {
|
|
it('still parses a stored disabledDefaultServerEnvVars value so existing databases keep loading', () => {
|
|
const prefs = UserPreferencesSchema.parse({
|
|
...DEFAULT_USER_PREFERENCES,
|
|
disabledDefaultServerEnvVars: ['NODE_OPTIONS'],
|
|
})
|
|
|
|
expect(prefs.disabledDefaultServerEnvVars).toEqual(['NODE_OPTIONS'])
|
|
})
|
|
})
|
|
|
|
describe('sandbox config', () => {
|
|
afterEach(() => {
|
|
delete process.env.SANDBOX_IMAGE
|
|
})
|
|
|
|
it('defaults sandbox.enabled to false in the persisted preference contract', () => {
|
|
const prefs = UserPreferencesSchema.parse(DEFAULT_USER_PREFERENCES)
|
|
expect(prefs.sandbox?.enabled).toBe(false)
|
|
})
|
|
|
|
it('round-trips sandbox.enabled when set to true', () => {
|
|
const prefs = UserPreferencesSchema.parse({
|
|
...DEFAULT_USER_PREFERENCES,
|
|
sandbox: { enabled: true },
|
|
})
|
|
expect(prefs.sandbox).toEqual({ enabled: true })
|
|
})
|
|
|
|
it('falls back ENV.SANDBOX.IMAGE to the default when SANDBOX_IMAGE is unset', async () => {
|
|
delete process.env.SANDBOX_IMAGE
|
|
vi.resetModules()
|
|
const { ENV } = await import('@opencode-manager/shared/config/env')
|
|
const { DEFAULTS } = await import('@opencode-manager/shared/config/defaults')
|
|
expect(ENV.SANDBOX.IMAGE).toBe(DEFAULTS.SANDBOX.IMAGE)
|
|
})
|
|
|
|
it('honors SANDBOX_IMAGE when set before module import', async () => {
|
|
process.env.SANDBOX_IMAGE = 'node:22-alpine'
|
|
vi.resetModules()
|
|
const { ENV } = await import('@opencode-manager/shared/config/env')
|
|
expect(ENV.SANDBOX.IMAGE).toBe('node:22-alpine')
|
|
})
|
|
})
|