#10275 · @jerome-benoit · opened Jan 23, 2026 at 4:45 PM UTC · last updated Mar 21, 2026 at 11:31 AM UTC
feat(bun): track provider packages for automatic cleanup
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR implements a new system to track provider-to-package mappings in package.json to enable automatic cleanup of unused SDK packages. It aims to prevent package accumulation by only removing packages when no provider still uses them.
Description
Fixes #10276
What changed
Track provider→package mappings in package.json under opencode.providers. Reference counting ensures packages are only removed when no provider uses them.
Key changes:
- Add
opencode.providerssection to track which provider uses which package - Cleanup old packages only after successful install (not before)
- Check if other providers still use a package before removing it
- Handle
version=latestwithPackageRegistry.isOutdated()for proper staleness detection - Refactor helpers:
readPackageJson,writePackageJson,track,cleanup,resolveVersion,finalize - Refactor
BunProc.run()to useProcess.run()pattern (matchesgit.tsconventions) - Harmonize
registry.tsto useBunProc.which()instead of duplicate implementation
How to verify
cd packages/opencode
bun test ./test/bun.test.ts
bun test --coverage ./test/bun.test.ts
25 tests cover the full decision tree for BunProc.install().
Linked Issues
#10276 Provider SDK packages accumulate in cache when switching
View issueComments
PR comments
jerome-benoit
@rekram1-node: hello, that PR is covering all packages cache use cases in tests, it will avoid as much as possible any regression in the future.
Changed Files
packages/opencode/src/bun/index.ts
+89−61packages/opencode/src/bun/registry.ts
+5−6packages/opencode/src/global/index.ts
+4−1packages/opencode/src/provider/provider.ts
+1−1packages/opencode/test/bun.test.ts
+386−37