anomalyco / anomalyco/opencode

plugins for V2: local plugin paths fail to load (file entries rejected, @opencode/plugin unresolvable)

Open
#49,608 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 17, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

A local plugin cannot be loaded by following the documentation.

  1. A plugins entry pointing at a .ts file is rejected with
    WARN "configured plugin path must be a directory", and the plugin never loads. The plugins
    documentation shows exactly this form (./plugins/local, ../shared/plugin.ts,
    /absolute/path/plugin.ts, file:///home/me/plugins/local).

  2. An entry pointing at a directory (or a plugin discovered under .opencode/plugins/) is found and
    imported, but loading fails because the documented import is not resolvable:

    level=INFO  message="loading plugin"  id=…/mi-plugin  entrypoint=file:///…/mi-plugin/index.ts
    level=WARN  message="failed to load plugin"
      cause="Cause([Die(ResolveMessage: Cannot find package '@opencode/plugin' imported from …\mi-plugin\index.ts)])"
    

    This happens with both loading paths (config entry and discovery). It only works if the plugin
    directory ships its own node_modules.

In both cases the failure is silent outside the log — no error in the session, no hint in the TUI —
so the only visible symptom is that the plugin's tools and hooks do not exist.

Plugins

None configured globally. The reproductions use a single project entry in opencode.jsonc and a
directory under .opencode/plugins/.

OpenCode version

2.0.3 (@opencode/cli installed globally with npm)

Steps to reproduce

A. plugins entry pointing at a .ts file

  1. Create a local plugin with a single default export: export default { id: "x", setup() {} }.

  2. Configure the entry: { "plugins": ["C:/absolute/path/mi-plugin/index.ts"] }.

  3. Start any session in that project (opencode run --standalone --print-logs --log-level info).

    Log: level=WARN message="configured plugin path must be a directory" target=C:/absolute/path/mi-plugin/index.ts

B. Directory entry or .opencode/plugins/ discovery importing @opencode/plugin

  1. Create <project>/.opencode/plugins/mi-plugin/index.ts:

    import { Plugin } from "@opencode/plugin"
    
    export default Plugin.define({
      id: "mi-plugin",
      async setup() {},
    })
    
  2. Start a session in that project.

    The module is found, then loading fails with the Cannot find package '@opencode/plugin' cause above.

Screenshot and/or share link

N/A — both failures are only visible in the server log; the log lines are quoted above.

Operating System

Windows 10 Enterprise LTSC 10.0.19044 (x64)

Terminal

Not applicable: reproduced headlessly with opencode run --standalone from PowerShell 5.1
(TERM=xterm-256color, TERM_PROGRAM unset, %COMSPEC% = cmd.exe).


Additional context (not part of the form):

  • Workarounds that work: export a plain object (export default { id, setup }) instead of
    Plugin.define; or run an install inside the plugin directory so @opencode/plugin resolves
    locally (@opencode/plugin@2.0.5 is published on npm).
  • Why this matters: the first case is a documentation/behaviour mismatch, and the second blocks
    every local (non-published) plugin that follows the documented import. Both fail silently, which
    makes them expensive to diagnose.
  • Notes: tested with the path written as C:/… and C:\…; opencode plugin list does not load
    project plugins, so it cannot be used to verify. Reproduced consistently on 2.0.3.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.