feat(opencode): migrate OpenCode Manager to OpenCode 2 (#359)

* 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
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-26 13:16:45 -04:00
1 parent 6c2ebd764b
commit dacde879d6
383 files changed
+29905 -46566

No files matched your search

@@ -12,7 +12,6 @@ import { useAgents } from '@/hooks/useOpenCode'
import { getAgentStyleVars } from '@/lib/agent-colors'
interface AgentQuickSelectProps {
opcodeUrl: string | null | undefined
directory?: string
currentAgent: string
onAgentChange: (agent: string) => void
@@ -20,6 +19,7 @@ interface AgentQuickSelectProps {
}
interface AgentInfo {
id: string
name: string
color?: string
description?: string
@@ -27,8 +27,8 @@ interface AgentInfo {
hidden?: boolean
}
const findAgentColor = (agents: AgentInfo[], agentName: string): string | undefined => {
return agents.find(a => a.name.toLowerCase() === agentName.toLowerCase())?.color
const findAgent = (agents: AgentInfo[], agentId: string): AgentInfo | undefined => {
return agents.find(a => a.id.toLowerCase() === agentId.toLowerCase())
}
const bashStyleVars: Record<string, string> = {
@@ -49,13 +49,12 @@ const bashStyleVars: Record<string, string> = {
}
export function AgentQuickSelect({
opcodeUrl,
directory,
currentAgent,
onAgentChange,
isBashMode = false,
}: AgentQuickSelectProps) {
const { data: agents = [] } = useAgents(opcodeUrl, directory)
const { data: agents = [] } = useAgents(directory)
const primaryAgents = useMemo(() => {
return agents.filter(
@@ -65,14 +64,15 @@ export function AgentQuickSelect({
)
}, [agents])
const handleSelect = (agentName: string) => {
onAgentChange(agentName)
const handleSelect = (agentId: string) => {
onAgentChange(agentId)
}
const currentAgentInfo = findAgent(agents, currentAgent)
const styleVars = isBashMode
? bashStyleVars
: getAgentStyleVars(currentAgent, findAgentColor(agents, currentAgent))
const displayName = isBashMode ? 'Bash' : capitalize(currentAgent)
: getAgentStyleVars(currentAgent, currentAgentInfo?.color)
const displayName = isBashMode ? 'Bash' : capitalize(currentAgentInfo?.name ?? currentAgent)
const buttonContent = (
<button
@@ -92,13 +92,13 @@ export function AgentQuickSelect({
<DropdownMenuContent align="start" className="w-64">
{primaryAgents.map((agent) => {
const apiColor = agent.color
const itemStyleVars = getAgentStyleVars(agent.name, apiColor)
const isSelected = agent.name.toLowerCase() === currentAgent.toLowerCase()
const itemStyleVars = getAgentStyleVars(agent.id, apiColor)
const isSelected = agent.id.toLowerCase() === currentAgent.toLowerCase()
return (
<DropdownMenuItem
key={agent.name}
onClick={() => handleSelect(agent.name)}
key={agent.id}
onClick={() => handleSelect(agent.id)}
className="group flex items-center justify-between"
>
<div className="flex flex-col min-w-0">