[PR #7611] feat(opencode): add plugin management CLI commands #12454

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

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

State: open
Merged: No


Summary

Add CLI commands for managing OpenCode plugins, addressing the need for easy plugin updates without manual config editing.

Fixes #6159

Changes

Add opencode plugin subcommand with:

  • list - List installed plugins with current/latest version comparison
  • update [name] - Update all or specific plugin to latest version
  • add <name> - Add a plugin to config
  • remove <name> - Remove a plugin from config

Implementation Details

  • Uses existing utilities: Config.getPluginName() for consistent name extraction, BunProc.install() for package installation
  • Scoped package support: URL-encodes package names for npm registry fetches (@scope/pkg%40scope%2Fpkg)
  • Input normalization: update foo@1.0 and remove foo@1.0 correctly match foo plugin
  • Config validation: Safely handles non-array plugin field
  • Atomic config writes: Uses temp file + rename pattern to prevent corruption
  • Proper error handling: Distinguishes ENOENT (create new) from JSON parse errors (throw)
  • Truthful status reporting: Shows "latest unknown" when registry fetch fails instead of "up to date"
  • Spinner lifecycle: Properly stops spinner before re-starting

Demo Output

$ opencode plugin list
┌  Installed Plugins
◇  Version check complete
│
●  ✓ oh-my-opencode 2.14.0
●  ⬆ opencode-anthropic-auth 0.0.7 → 0.0.8
●  ! @scope/plugin 1.0.0 (latest unknown)
│
└  3 plugin(s), 1 update(s) available, 1 check(s) failed. Run: opencode plugin update

$ opencode plugin update
┌  Update Plugins
●    opencode-anthropic-auth 0.0.7 → 0.0.8
◇  ✓ opencode-anthropic-auth updated to 0.0.8
│
└  1 plugin(s) updated

How to verify

# List plugins and their versions
opencode plugin list

# Add a new plugin
opencode plugin add example-plugin

# Update all plugins
opencode plugin update

# Update specific plugin (accepts name with or without version)
opencode plugin update oh-my-opencode
opencode plugin update oh-my-opencode@2.0.0  # also works

# Remove a plugin (accepts name with or without version)
opencode plugin remove example-plugin
opencode plugin remove example-plugin@1.0.0  # also works

Testing Done

  • plugin list - shows installed plugins with version info
  • plugin list - shows "latest unknown" when fetch fails
  • plugin update - updates all plugins to latest
  • plugin update <name> - updates specific plugin
  • plugin update <name>@<version> - normalizes input correctly
  • plugin add <name> - installs and adds plugin to config
  • plugin add <name>@<version> - installs specific version
  • plugin remove <name> - removes plugin from config
  • plugin remove <name>@<version> - normalizes input correctly
  • Error case: plugin not found (shows available plugins)
  • Error case: npm fetch failure (reports as skipped)
  • Local file:// plugins are skipped appropriately
  • Typecheck passes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7611 **State:** open **Merged:** No --- ## Summary Add CLI commands for managing OpenCode plugins, addressing the need for easy plugin updates without manual config editing. Fixes #6159 ## Changes Add `opencode plugin` subcommand with: - `list` - List installed plugins with current/latest version comparison - `update [name]` - Update all or specific plugin to latest version - `add <name>` - Add a plugin to config - `remove <name>` - Remove a plugin from config ## Implementation Details - **Uses existing utilities**: `Config.getPluginName()` for consistent name extraction, `BunProc.install()` for package installation - **Scoped package support**: URL-encodes package names for npm registry fetches (`@scope/pkg` → `%40scope%2Fpkg`) - **Input normalization**: `update foo@1.0` and `remove foo@1.0` correctly match `foo` plugin - **Config validation**: Safely handles non-array `plugin` field - **Atomic config writes**: Uses temp file + rename pattern to prevent corruption - **Proper error handling**: Distinguishes ENOENT (create new) from JSON parse errors (throw) - **Truthful status reporting**: Shows "latest unknown" when registry fetch fails instead of "up to date" - **Spinner lifecycle**: Properly stops spinner before re-starting ## Demo Output ``` $ opencode plugin list ┌ Installed Plugins ◇ Version check complete │ ● ✓ oh-my-opencode 2.14.0 ● ⬆ opencode-anthropic-auth 0.0.7 → 0.0.8 ● ! @scope/plugin 1.0.0 (latest unknown) │ └ 3 plugin(s), 1 update(s) available, 1 check(s) failed. Run: opencode plugin update $ opencode plugin update ┌ Update Plugins ● opencode-anthropic-auth 0.0.7 → 0.0.8 ◇ ✓ opencode-anthropic-auth updated to 0.0.8 │ └ 1 plugin(s) updated ``` ## How to verify ```bash # List plugins and their versions opencode plugin list # Add a new plugin opencode plugin add example-plugin # Update all plugins opencode plugin update # Update specific plugin (accepts name with or without version) opencode plugin update oh-my-opencode opencode plugin update oh-my-opencode@2.0.0 # also works # Remove a plugin (accepts name with or without version) opencode plugin remove example-plugin opencode plugin remove example-plugin@1.0.0 # also works ``` ## Testing Done - [x] `plugin list` - shows installed plugins with version info - [x] `plugin list` - shows "latest unknown" when fetch fails - [x] `plugin update` - updates all plugins to latest - [x] `plugin update <name>` - updates specific plugin - [x] `plugin update <name>@<version>` - normalizes input correctly - [x] `plugin add <name>` - installs and adds plugin to config - [x] `plugin add <name>@<version>` - installs specific version - [x] `plugin remove <name>` - removes plugin from config - [x] `plugin remove <name>@<version>` - normalizes input correctly - [x] Error case: plugin not found (shows available plugins) - [x] Error case: npm fetch failure (reports as skipped) - [x] Local file:// plugins are skipped appropriately - [x] Typecheck passes
yindo added the pull-request label 2026-02-16 18:17:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12454