Skip to content

Plugin loader always attempts npm install, failing for local/non-published packages #3

Description

@henengelh

Problem

When a plugin listed in opencode.json does not exist on npm, the plugin loader
fails with a 404 error and silently swallows the plugin — providers login then
returns "Unknown provider" with no actionable message.

The loader unconditionally runs:
opencode add --force --exact --ignore-scripts --cwd ~/.cache/opencode @latest

even when the package is already present in node_modules or when a local path is intended.

Reproduction

  1. Create a local plugin at ~/.config/opencode/node_modules/my-plugin/
  2. Add "plugin": ["my-plugin"] to opencode.json
  3. Run opencode providers login --provider <id-registered-by-plugin>
  4. Result: "Unknown provider" (npm 404 kills loading silently)

Workaround

Use the absolute path to the plugin directory instead of the package name:

"plugin": ["/Users/<you>/.config/opencode/node_modules/my-plugin"]                                                                                                                                               

This skips the npm install step and loads directly from disk.

Expected behaviour

  • If the plugin value is an absolute/relative path, skip npm and load directly.
  • If npm install fails, fall back to an existing local copy if present.
  • Surface the 404/install failure to the user with a clear error message
    rather than "Unknown provider".

Environment

opencode 1.3.13, macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions