Skip to content

Plugin fails to load in OpenCode: missing package.json entry point + no compiled output #6

@gpid007

Description

@gpid007

Summary

opencode-worktree@0.4.1 crashes on startup when loaded as an OpenCode plugin, triggering a session.error that prevents the session from initialising cleanly.

Error

ERROR service=plugin path=/home/…/.cache/opencode/node_modules/opencode-worktree
  error=ResolveMessage: Cannot find module ‧/home/…/.cache/opencode/node_modules/opencode-worktree‧
  from ‧/$bunfs/root/src/cli/cmd/tui/worker.js‧
  failed to load plugin
INFO  service=bus type=session.error publishing

Root causes

1. package.json has no main or exports field

package.json declares "type": "module" but provides no main, module, or exports field to tell Node/Bun which file is the entry point. When OpenCode calls import(‧opencode-worktree‧) it cannot resolve the package.

2. No compiled JavaScript is shipped

src/ contains only raw TypeScript source files:

src/cli.ts
src/config.ts
src/git.ts
src/hooks.ts
src/opencode.ts
src/types.ts
src/ui.ts
src/update-check.ts

OpenCode runs inside a bundled Bun binary (/$bunfs/root/…) and cannot transpile .ts files on the fly. A compiled .js/.mjs artifact must be present and referenced via exports/main.

3. No OpenCode plugin API surface

The source does not export any OpenCode plugin hooks (e.g. definePlugin, register). The package appears to be a standalone CLI TUI, not a loadable plugin module. If that is intentional, the README/docs should clarify it must not be added to the "plugin" array in opencode.jsonc, or explain an alternative installation path.

Reproduction

  1. Add "opencode-worktree@0.4.1" to the plugin array in ~/.config/opencode/opencode.jsonc
  2. Start any OpenCode session
  3. Observe ERROR … failed to load plugin + session.error in the OpenCode log

Expected behaviour

Either the plugin loads successfully (requires a compiled JS entry point referenced in exports/main), or the README clarifies it is a standalone binary and should not be used as an OpenCode plugin.

Environment

  • opencode-worktree: 0.4.1
  • Platform: Linux (x86_64), WSL2
  • OpenCode runtime: bundled Bun (/$bunfs/root/…)

Workaround

Comment out the plugin entry in opencode.jsonc:

// "opencode-worktree@0.4.1"

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