opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(bun): always check for updates when plugin version is implied latest

Open backnotprop opened this issue 2 weeks ago • 1 comments

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., @[email protected]) 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

backnotprop avatar Jan 03 '26 20:01 backnotprop