[PR #12352] fix(core): install npm plugins into config directories instead of cache #14183

Closed
opened 2026-02-16 18:18:59 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: No


Summary

  • Fixes #12222 — plugins are now installed into the config directory that declared them (e.g. ~/.config/opencode/ or .opencode/) instead of ~/.cache/opencode/
  • Built-in plugins are installed into ~/.config/opencode/ (the global config directory)
  • Plugin data files now survive cache version bumps since they're no longer in the volatile cache directory

Problem

Previously, all npm plugins (oh-my-opencode, opencode-antigravity-auth, etc.) were installed into ~/.cache/opencode/node_modules/ via BunProc.install(). This had several issues:

  1. Cache is volatile~/.cache/opencode/ gets wiped on cache version bumps (CACHE_VERSION changes), destroying plugin data files
  2. No isolation — all plugins from all config sources (global, project, .opencode/) shared a single flat node_modules/, so version conflicts were possible
  3. Confusing pathsinstallDependencies() already ran bun install in each config directory but only installed @opencode-ai/plugin there, while actual user plugins went elsewhere

Solution

  • installDependencies(dir, plugins?) now accepts the list of npm plugins declared in that directory's config and adds them to the directory's package.json before running bun install
  • needsInstall(dir, plugins?) checks whether any declared plugins are missing from the directory
  • plugin/index.ts resolves npm plugins from config directories' node_modules/ instead of calling BunProc.install() into cache
  • Builtin plugins are assigned to the global config directory (~/.config/opencode/)
  • BUILTIN_PLUGINS constant extracted to plugin/builtin.ts to avoid circular imports

Testing

All 882 existing tests pass. The config test suite (57 tests) continues to pass with the new plugin installation logic.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12352 **State:** closed **Merged:** No --- ## Summary - Fixes #12222 — plugins are now installed into the config directory that declared them (e.g. `~/.config/opencode/` or `.opencode/`) instead of `~/.cache/opencode/` - Built-in plugins are installed into `~/.config/opencode/` (the global config directory) - Plugin data files now survive cache version bumps since they're no longer in the volatile cache directory ## Problem Previously, all npm plugins (`oh-my-opencode`, `opencode-antigravity-auth`, etc.) were installed into `~/.cache/opencode/node_modules/` via `BunProc.install()`. This had several issues: 1. **Cache is volatile** — `~/.cache/opencode/` gets wiped on cache version bumps (`CACHE_VERSION` changes), destroying plugin data files 2. **No isolation** — all plugins from all config sources (global, project, `.opencode/`) shared a single flat `node_modules/`, so version conflicts were possible 3. **Confusing paths** — `installDependencies()` already ran `bun install` in each config directory but only installed `@opencode-ai/plugin` there, while actual user plugins went elsewhere ## Solution - `installDependencies(dir, plugins?)` now accepts the list of npm plugins declared in that directory's config and adds them to the directory's `package.json` before running `bun install` - `needsInstall(dir, plugins?)` checks whether any declared plugins are missing from the directory - `plugin/index.ts` resolves npm plugins from config directories' `node_modules/` instead of calling `BunProc.install()` into cache - Builtin plugins are assigned to the global config directory (`~/.config/opencode/`) - `BUILTIN_PLUGINS` constant extracted to `plugin/builtin.ts` to avoid circular imports ## Testing All 882 existing tests pass. The config test suite (57 tests) continues to pass with the new plugin installation logic.
yindo added the pull-request label 2026-02-16 18:18:59 -05:00
yindo closed this issue 2026-02-16 18:18:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14183