Files
opencode-manager/scripts/setup-dev.sh
Chris Scott dacde879d6 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
2026-09-26 13:16:45 -04:00

84 lines
2.5 KiB
Bash

#!/bin/bash
set -e
echo "🔍 Checking prerequisites..."
# Check if pnpm is installed (required for workspaces)
if ! command -v pnpm &> /dev/null; then
echo "❌ pnpm is not installed. Please install it with:"
echo " npm install -g pnpm"
exit 1
fi
echo "✅ pnpm is installed"
# Check if Bun is installed (required for backend)
if ! command -v bun &> /dev/null; then
echo "❌ Bun is not installed. Please install it from https://bun.sh"
exit 1
fi
echo "✅ Bun is installed"
# Check if Git is installed
if ! git --version &> /dev/null; then
echo "❌ Git is not installed. Please install Git and try again."
exit 1
fi
echo "✅ Git is installed"
# Check if OpenCode TUI is installed
if ! opencode --version &> /dev/null; then
echo "❌ OpenCode TUI is not installed. Please install it with:"
echo " curl -fsSL https://opencode.ai/v2/install | bash"
exit 1
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_VERSION="$(opencode --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)"
if [ -z "$OPENCODE_SUPPORTED_FLOOR" ] || ! is_supported_opencode_version "$OPENCODE_VERSION"; then
echo "❌ OpenCode ${OPENCODE_VERSION:-unknown} is not supported; OpenCode $(supported_opencode_range) is required. Please install it with:"
echo " curl -fsSL https://opencode.ai/v2/install | bash"
exit 1
fi
echo "✅ OpenCode TUI is installed"
# Create workspace directory if it doesn't exist
WORKSPACE_PATH="./workspace"
if [ ! -d "$WORKSPACE_PATH" ]; then
echo "📁 Creating workspace directory at $WORKSPACE_PATH..."
mkdir -p "$WORKSPACE_PATH/repos"
mkdir -p "$WORKSPACE_PATH/config"
echo "✅ Workspace directory created"
else
echo "✅ Workspace directory exists"
fi
# Install dependencies using pnpm (handles workspaces)
echo "📦 Installing dependencies..."
pnpm install
echo "✅ Dependencies installed"
# Copy environment file if it doesn't exist
if [ ! -f ".env" ]; then
echo "📝 Creating environment file..."
cp .env.example .env
echo "✅ Environment file created from .env.example"
else
echo "✅ Environment file exists"
fi
echo "✅ Dev environment ready!"
echo ""
echo "🚀 To start development:"
echo " pnpm dev # Start both backend and frontend"
echo " pnpm dev:backend # Start backend only"
echo " pnpm dev:frontend # Start frontend only"