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 (#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:
1 parent
6c2ebd764b
commit
dacde879d6
383 files changed
+29905
-46566
No files matched your search
@@ -6,6 +6,7 @@ export BUN_INSTALL="$HOME/.bun"
|
||||
export PATH="$BUN_INSTALL/bin:$HOME/.opencode/bin:/usr/local/bin:$PATH"
|
||||
|
||||
source /usr/local/lib/ocm/container-user.sh
|
||||
source /usr/local/lib/ocm/opencode-release.sh
|
||||
|
||||
grant_kvm_access() {
|
||||
local dev="${1:-/dev/kvm}"
|
||||
@@ -42,11 +43,7 @@ grant_kvm_access() {
|
||||
echo "Granted node access to $dev (group '$group_name', gid $dev_gid)"
|
||||
}
|
||||
|
||||
MIN_OPENCODE_VERSION="1.0.137"
|
||||
|
||||
version_gte() {
|
||||
printf '%s\n%s\n' "$2" "$1" | sort -V -C
|
||||
}
|
||||
OPENCODE_SUPPORTED_FLOOR="${OPENCODE_BUNDLED_VERSION:-}"
|
||||
|
||||
read_opencode_version() {
|
||||
local binary
|
||||
@@ -63,24 +60,8 @@ install_opencode() {
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION is not set; refusing to guess the pinned OpenCode build" >&2
|
||||
return 1
|
||||
fi
|
||||
if [[ ! "$opencode_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION='$opencode_version' is not an X.Y.Z version; refusing to download it" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! version_gte "$opencode_version" "$MIN_OPENCODE_VERSION"; then
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION=$opencode_version is below the minimum supported $MIN_OPENCODE_VERSION; refusing to download it" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Installing OpenCode ${opencode_version}..."
|
||||
local staging
|
||||
staging="$(mktemp -d)"
|
||||
curl -fsSL "https://github.com/anomalyco/opencode/releases/download/v${opencode_version}/opencode-linux-$(uname -m | sed 's/x86_64/x64/; s/aarch64/arm64/').tar.gz" \
|
||||
-o "$staging/opencode.tar.gz"
|
||||
tar -xzf "$staging/opencode.tar.gz" -C "$staging"
|
||||
mkdir -p "$HOME/.opencode/bin"
|
||||
mv "$staging/opencode" "$HOME/.opencode/bin/opencode"
|
||||
chmod 755 "$HOME/.opencode/bin/opencode"
|
||||
rm -rf "$staging"
|
||||
download_opencode_to "$opencode_version" "$HOME/.opencode/bin/opencode"
|
||||
}
|
||||
|
||||
reconcile_persisted_opencode() {
|
||||
@@ -93,6 +74,11 @@ reconcile_persisted_opencode() {
|
||||
rm -f "$persisted_path"
|
||||
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"
|
||||
rm -f "$persisted_path"
|
||||
return 0
|
||||
fi
|
||||
echo "Persisted OpenCode $persisted_version is usable; retaining it"
|
||||
}
|
||||
|
||||
@@ -133,10 +119,10 @@ OPENCODE_VERSION="$(read_opencode_version)"
|
||||
echo "OpenCode is installed (version: $OPENCODE_VERSION)"
|
||||
|
||||
if [ "$OPENCODE_VERSION" != "unknown" ]; then
|
||||
if version_gte "$OPENCODE_VERSION" "$MIN_OPENCODE_VERSION"; then
|
||||
echo "OpenCode version meets minimum requirement (>=$MIN_OPENCODE_VERSION)"
|
||||
if is_supported_opencode_version "$OPENCODE_VERSION"; then
|
||||
echo "OpenCode version is within the supported range $(supported_opencode_range)"
|
||||
else
|
||||
echo "OpenCode version $OPENCODE_VERSION is below minimum required version $MIN_OPENCODE_VERSION"
|
||||
echo "OpenCode version $OPENCODE_VERSION is outside the supported range $(supported_opencode_range)"
|
||||
echo "Reinstalling bundled OpenCode version ${OPENCODE_BUNDLED_VERSION}..."
|
||||
install_opencode
|
||||
|
||||
|
||||
Reference in new issue
Block a user