opencode
opencode copied to clipboard
fix(bun): always check for updates when plugin version is implied latest
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:
- First start:
version = "latest", installs package, resolves to"0.2.3" - Saves
"@plannotator/opencode": "0.2.3"to cache - Next start:
version = "latest", cache has"0.2.3" - Check:
"0.2.3" === "latest"→ false → proceeds to reinstall - But
bun add --forceuses 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 addto 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