[PR #6772] fix(bun): always check for updates when plugin version is implied latest #12096

Open
opened 2026-02-16 18:17:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6772

State: open
Merged: No


Summary

Fixes an issue where plugins configured with implied "latest" version (or no version) were not updating to newer versions on subsequent OpenCode starts.

Problem

When a user configures a plugin like:

{
  "plugin": ["@plannotator/opencode"]
}

The install flow was:

  1. First start: version = "latest", installs package, resolves to "0.2.3"
  2. Saves "@plannotator/opencode": "0.2.3" to cache
  3. Next start: version = "latest", cache has "0.2.3"
  4. Check: "0.2.3" === "latest" → false → proceeds to reinstall
  5. But bun add --force uses cached registry data, doesn't fetch new version

Users were stuck on old versions unless they manually cleared ~/.cache/opencode/.

Solution

Skip the early cache return when version === "latest":

// Before
if (parsed.dependencies[pkg] === version) return mod

// After  
if (version !== "latest" && parsed.dependencies[pkg] === version) return mod

This ensures:

  • Pinned versions (e.g., @pkg@1.0.0) still skip reinstalls via cache
  • Latest versions always run bun add to check for updates

Test plan

  • Configure a plugin with "latest" version
  • Verify it updates when a new version is published
  • Verify pinned versions still skip unnecessary reinstalls
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6772 **State:** open **Merged:** No --- ## Summary Fixes an issue where plugins configured with implied `"latest"` version (or no version) were not updating to newer versions on subsequent OpenCode starts. ## Problem When a user configures a plugin like: ```json { "plugin": ["@plannotator/opencode"] } ``` The install flow was: 1. First start: `version = "latest"`, installs package, resolves to `"0.2.3"` 2. Saves `"@plannotator/opencode": "0.2.3"` to cache 3. Next start: `version = "latest"`, cache has `"0.2.3"` 4. Check: `"0.2.3" === "latest"` → false → proceeds to reinstall 5. But `bun add --force` uses cached registry data, doesn't fetch new version Users were stuck on old versions unless they manually cleared `~/.cache/opencode/`. ## Solution Skip the early cache return when `version === "latest"`: ```typescript // Before if (parsed.dependencies[pkg] === version) return mod // After if (version !== "latest" && parsed.dependencies[pkg] === version) return mod ``` This ensures: - **Pinned versions** (e.g., `@pkg@1.0.0`) still skip reinstalls via cache - **Latest versions** always run `bun add` to check for updates ## Test plan - [ ] Configure a plugin with `"latest"` version - [ ] Verify it updates when a new version is published - [ ] Verify pinned versions still skip unnecessary reinstalls
yindo added the pull-request label 2026-02-16 18:17:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12096