GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "fix(cli): prevent repeated updates and npm cache growth" (#45… · jinhuang712/opencode@f8b0191

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/cli/src/services
    • fixtures
      • updater.ts
    • updater-action.ts
    • updater.test.ts
    • updater.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/cli/src/services/fixtures/updater.ts‎

Copy file name to clipboardExpand all lines: packages/cli/src/services/fixtures/updater.ts
-58Lines changed: 0 additions & 58 deletions
This file was deleted.
Collapse file

‎packages/cli/src/services/updater-action.ts‎

Copy file name to clipboardExpand all lines: packages/cli/src/services/updater-action.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const maximumComponent = "9007199254740991"
55
const versionPattern =
66
/^v?([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
77

8-
export function action(current: string, latest: string, policy: Policy, installed = current): Action {
8+
export function action(current: string, latest: string, policy: Policy): Action {
99
if (policy === false) return "none"
10-
const currentVersion = parseReleaseVersion(installed)
10+
const currentVersion = parseReleaseVersion(current)
1111
const latestVersion = parseReleaseVersion(latest)
1212
if (!currentVersion || !latestVersion || sameRelease(currentVersion, latestVersion)) return "none"
1313
// Major upgrades are never installed automatically.
Collapse file

‎packages/cli/src/services/updater.test.ts‎

Copy file name to clipboardExpand all lines: packages/cli/src/services/updater.test.ts
-30Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
11
import { describe, expect, test } from "bun:test"
2-
import path from "node:path"
32
import { action } from "./updater-action"
43
import { decodePolicy } from "./updater"
54

65
describe("updater", () => {
7-
test("remembers successful installs across checks and accepts the next release", async () => {
8-
// Isolate compiled version constants and the update endpoint from other tests.
9-
const child = Bun.spawn(
10-
[
11-
process.execPath,
12-
"--define",
13-
'OPENCODE_VERSION="0.0.0-next-16473"',
14-
"--define",
15-
'OPENCODE_CHANNEL="beta"',
16-
path.join(import.meta.dir, "fixtures/updater.ts"),
17-
],
18-
{ env: { ...process.env, OPENCODE_DISABLE_AUTOUPDATE: "" }, stdout: "pipe", stderr: "pipe" },
19-
)
20-
const [code, stdout, stderr] = await Promise.all([
21-
child.exited,
22-
new Response(child.stdout).text(),
23-
new Response(child.stderr).text(),
24-
])
25-
expect(code, stdout + stderr).toBe(0)
26-
})
27-
286
test("reads autoupdate from JSONC", () => {
297
expect(decodePolicy('{ // preference\n "autoupdate": "notify",\n}')).toBe("notify")
308
expect(decodePolicy('{ "autoupdate": false }')).toBe(false)
@@ -54,14 +32,6 @@ describe("updater", () => {
5432
expect(action("1.2.3", "1.2.3", true)).toBe("none")
5533
})
5634

57-
test("skips an installed update but still accepts the next release", () => {
58-
const current = "0.0.0-next-16473"
59-
const installed = "0.0.0-beta-17498"
60-
expect(action(current, installed, true)).toBe("upgrade")
61-
expect(action(current, installed, true, installed)).toBe("none")
62-
expect(action(current, "0.0.0-beta-17499", true, installed)).toBe("upgrade")
63-
})
64-
6535
test("upgrades when latest is lower (rollback)", () => {
6636
expect(action("1.2.4", "1.2.3", true)).toBe("upgrade")
6737
})
Collapse file

‎packages/cli/src/services/updater.ts‎

Copy file name to clipboardExpand all lines: packages/cli/src/services/updater.ts
+11-15Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Global } from "@opencode-ai/util/global"
22
import { AppProcess } from "@opencode-ai/util/process"
33
import { OPENCODE_CHANNEL, OPENCODE_LOCAL, OPENCODE_VERSION } from "../version"
4-
import { Context, Duration, Effect, FileSystem, Layer, Ref } from "effect"
4+
import { Context, Duration, Effect, FileSystem, Layer } from "effect"
55
import { ChildProcess } from "effect/unstable/process"
66
import { parse, type ParseError } from "jsonc-parser"
77
import path from "node:path"
@@ -38,7 +38,6 @@ export const layer = Layer.effect(
3838
const fs = yield* FileSystem.FileSystem
3939
const global = yield* Global.Service
4040
const appProcess = yield* AppProcess.Service
41-
const installed = yield* Ref.make(OPENCODE_VERSION)
4241
const channel = OPENCODE_CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-")
4342

4443
const readPolicy = Effect.fnUntraced(function* () {
@@ -113,20 +112,18 @@ export const layer = Layer.effect(
113112

114113
const upgrade = Effect.fnUntraced(function* (method: Method, version: string) {
115114
const target = `${packageName}@${version}`
116-
const commands: Record<Exclude<Method, "bun" | "curl" | "npm">, string[]> = {
115+
const commands: Record<Exclude<Method, "bun" | "curl">, string[]> = {
116+
npm: ["npm", "install", "--global", target],
117117
pnpm: ["pnpm", "add", "--global", `--allow-build=${packageName}`, target],
118118
yarn: ["yarn", "global", "add", target],
119119
}
120120
const result = yield* Effect.scoped(
121121
Effect.gen(function* () {
122-
if (method === "bun" || method === "npm") {
122+
if (method === "bun") {
123+
// Bun does not prune old versions from its shared package cache.
123124
yield* fs.makeDirectory(global.cache, { recursive: true })
124125
const cache = yield* fs.makeTempDirectoryScoped({ directory: global.cache, prefix: "update-" })
125-
const command =
126-
method === "bun"
127-
? ["bun", "install", "--global", "--trust", "--cache-dir", cache, target]
128-
: ["npm", "install", "--global", "--cache", cache, target]
129-
return yield* run(command, "5 minutes")
126+
return yield* run(["bun", "install", "--global", "--trust", "--cache-dir", cache, target], "5 minutes")
130127
}
131128
if (method === "curl") {
132129
yield* fs.makeDirectory(global.cache, { recursive: true })
@@ -159,19 +156,18 @@ export const layer = Layer.effect(
159156

160157
return yield* Effect.gen(function* () {
161158
const version = yield* latest()
162-
const current = yield* Ref.get(installed)
163159
yield* Effect.logInfo("update check", {
164-
current,
160+
current: OPENCODE_VERSION,
165161
latest: version,
166162
})
167-
const next = action(OPENCODE_VERSION, version, policy, current)
163+
const next = action(OPENCODE_VERSION, version, policy)
168164
if (next === "none") return yield* Effect.logInfo("update check done", { action: "up-to-date" })
169-
if (next === "notify") return yield* Effect.logInfo("OpenCode update available", { current, latest: version })
165+
if (next === "notify")
166+
return yield* Effect.logInfo("OpenCode update available", { current: OPENCODE_VERSION, latest: version })
170167
const detected = yield* method()
171168
if (!detected) return yield* Effect.logWarning("automatic update skipped: installation method not found")
172169
yield* upgrade(detected, version)
173-
yield* Ref.set(installed, version)
174-
yield* Effect.logInfo("updated OpenCode", { from: current, to: version, method: detected })
170+
yield* Effect.logInfo("updated OpenCode", { from: OPENCODE_VERSION, to: version, method: detected })
175171
})
176172
},
177173
Effect.catchCause((cause) => Effect.logWarning("automatic update failed", { cause })),

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.