Skip to content

Fix plugin loading: move @opencode-ai/plugin to dependencies#48

Merged
Helweg merged 3 commits intoHelweg:mainfrom
hakanai3d:fix/plugin-loading-issues
Apr 8, 2026
Merged

Fix plugin loading: move @opencode-ai/plugin to dependencies#48
Helweg merged 3 commits intoHelweg:mainfrom
hakanai3d:fix/plugin-loading-issues

Conversation

@hakanai3d
Copy link
Copy Markdown
Contributor

@hakanai3d hakanai3d commented Apr 8, 2026

Summary

This PR fixes a plugin loading issue when installed via npm by moving @opencode-ai/plugin from devDependencies to dependencies.

The Problem

When the plugin is installed from npm, devDependencies are not included. This caused the plugin to fail with:
ERROR: Cannot find module '@opencode-ai/plugin'

Root Cause

The plugin expects @opencode-ai/plugin to be available at runtime (as a peer dependency provided by opencode). However, opencode's module resolution for npm plugins doesn't properly resolve peer dependencies from the global config directory.

This Fix

Moving @opencode-ai/plugin to dependencies ensures it's bundled with the plugin package, making module resolution work reliably.

  • EDIT:
    -- Version pinned to ~1.3.13 to prevent breaking changes while allowing patch updates
    -- @opencode-ai/plugin kept in peerDependencies for documentation purposes

Trade-offs:

  • Works immediately and reliably
  • No changes needed to opencode core
  • Duplicates @opencode-ai/plugin across plugin installations
  • Not architecturally ideal (peer dependency would be cleaner)

Alternative Approaches

A more elegant solution might be for opencode to:

  1. Provide @opencode-ai/plugin as a global peer dependency
  2. Set up module resolution to find it from ~/.config/opencode/node_modules/
    However, that requires changes to opencode core. This PR is a pragmatic fix that works with the current architecture.

Testing

After this fix, the plugin loads successfully and all tools are registered:

  • codebase_search - Search code by meaning
  • codebase_peek - Find code locations by meaning
  • index_codebase - Index codebase for search
  • index_status - Check index status
  • index_health_check - Check index health
  • index_metrics - Get index metrics
  • index_logs - Get indexer logs
  • find_similar - Find similar code
  • call_graph - Query function callers/callees
  • implementation_lookup - Find symbol definitions

- Moved @opencode-ai/plugin from devDependencies to dependencies
  This was causing 'Cannot find module @opencode-ai/plugin' errors
  when the plugin was installed via npm/bun without devDependencies

- The export format remains 'export default plugin' as originally intended
  by the package author
@github-actions github-actions bot added the dependencies Dependency updates label Apr 8, 2026
@Helweg
Copy link
Copy Markdown
Owner

Helweg commented Apr 8, 2026

If this is really needed because OpenCode doesn’t resolve peer deps reliably for npm plugins, I’m okay with it. I’d just prefer we pin @opencode-ai/plugin more tightly (exact or ~ rather than ^) and leave a quick note about why we’re doing this.

…ading

- Changed @opencode-ai/plugin from devDependencies to dependencies
- Pinned version to ~1.3.13 (patch updates only)
- Added inline comment explaining why: opencode downloads npm plugins
  without devDependencies, causing module resolution failures
- Kept peerDependency for documentation purposes
@Helweg
Copy link
Copy Markdown
Owner

Helweg commented Apr 8, 2026

The tighter pin looks good, but I think there’s one follow-up issue here: package.json can’t contain // comments, so the inline notes make the manifest invalid JSON. I’d move that explanation to the PR description/README/changelog and then regenerate package-lock.json as well so it matches the new ~1.3.13 range.

- Comments are not valid in JSON, causing manifest to be invalid
- Regenerated package-lock.json to match ~1.3.13 version range
@hakanai3d
Copy link
Copy Markdown
Contributor Author

doh comments in JSON! fixed

@Helweg Helweg merged commit 2d56dbf into Helweg:main Apr 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants