From 0a2f3680755bc05fb4a375fa7ea4b429b26da1a2 Mon Sep 17 00:00:00 2001 From: "will.anderson" Date: Fri, 21 Aug 2026 17:05:49 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20complete=20upgrade-machinery=20removal?= =?UTF-8?q?=20=E2=80=94=20drop=20/global/upgrade=20endpoint,=20gut=20passi?= =?UTF-8?q?ve=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/opencode/src/cli/upgrade.ts | 56 ++----------------- .../routes/instance/httpapi/groups/global.ts | 15 ----- .../instance/httpapi/handlers/global.ts | 53 ------------------ 3 files changed, 4 insertions(+), 120 deletions(-) diff --git a/packages/opencode/src/cli/upgrade.ts b/packages/opencode/src/cli/upgrade.ts index bf9b56be5..7ef726592 100644 --- a/packages/opencode/src/cli/upgrade.ts +++ b/packages/opencode/src/cli/upgrade.ts @@ -1,52 +1,4 @@ -import { Flag } from "@opencode-ai/core/flag/flag" -import { Installation } from "@/installation" -import { InstallationVersion } from "@opencode-ai/core/installation/version" -import { GlobalBus } from "@/bus/global" - -export async function upgrade() { - // Neuron fork: the passive update check is disabled. Set - // OPENCODE_ALWAYS_NOTIFY_UPDATE=1 to re-enable release notifications. - if (!Flag.OPENCODE_ALWAYS_NOTIFY_UPDATE) return - const method = await Installation.method() - const latest = await Installation.latest(method).catch(() => {}) - if (!latest) return - - if (Flag.OPENCODE_ALWAYS_NOTIFY_UPDATE) { - GlobalBus.emit("event", { - directory: "global", - payload: { - type: Installation.Event.UpdateAvailable.type, - properties: { version: latest }, - }, - }) - return - } - - if (InstallationVersion === latest) return - - const kind = Installation.getReleaseType(InstallationVersion, latest) - - if (kind !== "patch") { - GlobalBus.emit("event", { - directory: "global", - payload: { - type: Installation.Event.UpdateAvailable.type, - properties: { version: latest }, - }, - }) - return - } - - if (method === "unknown") return - await Installation.upgrade(method, latest) - .then(() => - GlobalBus.emit("event", { - directory: "global", - payload: { - type: Installation.Event.Updated.type, - properties: { version: latest }, - }, - }), - ) - .catch(() => {}) -} +// Neuron fork: self-update machinery has been lobotomized. +// The passive check is a no-op and the /global/upgrade server route is gone. +// Manual upgrades are impossible by design; rebuild from source instead. +export async function upgrade() {} diff --git a/packages/opencode/src/server/routes/instance/httpapi/groups/global.ts b/packages/opencode/src/server/routes/instance/httpapi/groups/global.ts index afdb32e81..d4bccccce 100644 --- a/packages/opencode/src/server/routes/instance/httpapi/groups/global.ts +++ b/packages/opencode/src/server/routes/instance/httpapi/groups/global.ts @@ -47,9 +47,6 @@ const GlobalEventSchema = Schema.Struct({ ]), }).annotate({ identifier: "GlobalEvent" }) -export const GlobalUpgradeInput = Schema.Struct({ - target: Schema.optional(Schema.String), -}) const GlobalUpgradeResult = Schema.Union([ Schema.Struct({ @@ -67,7 +64,6 @@ export const GlobalPaths = { event: "/global/event", config: "/global/config", dispose: "/global/dispose", - upgrade: "/global/upgrade", } as const export const GlobalApi = HttpApi.make("global").add( @@ -120,17 +116,6 @@ export const GlobalApi = HttpApi.make("global").add( description: "Clean up and dispose all Neuron instances, releasing all resources.", }), ), - HttpApiEndpoint.post("upgrade", GlobalPaths.upgrade, { - payload: [HttpApiSchema.NoContent, GlobalUpgradeInput], - success: described(GlobalUpgradeResult, "Upgrade result"), - error: HttpApiError.BadRequest, - }).annotateMerge( - OpenApi.annotations({ - identifier: "global.upgrade", - summary: "Upgrade opencode", - description: "Upgrade opencode to the specified version or latest if not specified.", - }), - ), ) .annotateMerge(OpenApi.annotations({ title: "global", description: "Global server routes." })), ) diff --git a/packages/opencode/src/server/routes/instance/httpapi/handlers/global.ts b/packages/opencode/src/server/routes/instance/httpapi/handlers/global.ts index c1f588d5a..0f3124be7 100644 --- a/packages/opencode/src/server/routes/instance/httpapi/handlers/global.ts +++ b/packages/opencode/src/server/routes/instance/httpapi/handlers/global.ts @@ -11,7 +11,6 @@ import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http" import { HttpApiBuilder } from "effect/unstable/httpapi" import * as Sse from "effect/unstable/encoding/Sse" import { RootHttpApi } from "../api" -import { GlobalUpgradeInput } from "../groups/global" function eventData(data: unknown): Sse.Event { return { @@ -94,63 +93,11 @@ export const globalHandlers = HttpApiBuilder.group(RootHttpApi, "global", (handl return true }) - const upgrade = Effect.fn("GlobalHttpApi.upgrade")(function* (ctx: { payload: typeof GlobalUpgradeInput.Type }) { - const method = yield* installation.method() - if (method === "unknown") { - return { - status: 400, - body: { success: false as const, error: "Unknown installation method" }, - } - } - const target = ctx.payload.target || (yield* installation.latest(method)) - const result = yield* installation.upgrade(method, target).pipe( - Effect.as({ status: 200, body: { success: true as const, version: target } }), - Effect.catch((err) => - Effect.succeed({ - status: 500, - body: { - success: false as const, - error: err instanceof Error ? err.message : String(err), - }, - }), - ), - ) - if (!result.body.success) return result - GlobalBus.emit("event", { - directory: "global", - payload: { - type: Installation.Event.Updated.type, - properties: { version: target }, - }, - }) - return result - }) - - const upgradeRaw = Effect.fn("GlobalHttpApi.upgradeRaw")(function* (ctx: { - request: HttpServerRequest.HttpServerRequest - }) { - const body = yield* Effect.orDie(ctx.request.text) - const json = parseBody(body) - if (json === undefined) { - return HttpServerResponse.jsonUnsafe({ success: false, error: "Invalid request body" }, { status: 400 }) - } - const payload = yield* Schema.decodeUnknownEffect(GlobalUpgradeInput)(json).pipe( - Effect.map((payload) => ({ valid: true as const, payload })), - Effect.catch(() => Effect.succeed({ valid: false as const })), - ) - if (!payload.valid) { - return HttpServerResponse.jsonUnsafe({ success: false, error: "Invalid request body" }, { status: 400 }) - } - const result = yield* upgrade({ payload: payload.payload }) - return HttpServerResponse.jsonUnsafe(result.body, { status: result.status }) - }) - return handlers .handle("health", health) .handleRaw("event", event) .handle("configGet", configGet) .handle("configUpdate", configUpdate) .handle("dispose", dispose) - .handleRaw("upgrade", upgradeRaw) }), )