[PR #10275] feat(bun): track provider packages for automatic cleanup #13388

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

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

State: open
Merged: No


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.providers section 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=latest with PackageRegistry.isOutdated() for proper staleness detection
  • Refactor helpers: readPackageJson, writePackageJson, track, cleanup, resolveVersion, finalize

How to verify

cd packages/opencode
bun test ./test/bun.test.ts
bun test --coverage ./test/bun.test.ts

19 tests cover the full decision tree for BunProc.install().

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10275 **State:** open **Merged:** No --- 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.providers` section 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=latest` with `PackageRegistry.isOutdated()` for proper staleness detection - Refactor helpers: `readPackageJson`, `writePackageJson`, `track`, `cleanup`, `resolveVersion`, `finalize` ## How to verify ```bash cd packages/opencode bun test ./test/bun.test.ts bun test --coverage ./test/bun.test.ts ``` 19 tests cover the full decision tree for `BunProc.install()`.
yindo added the pull-request label 2026-02-16 18:18:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13388