Skip to content

fix: export only default for opencode plugin loader compatibility#1

Open
bhodgens wants to merge 1 commit intodeiviuds:mainfrom
bhodgens:fix/export-default-only
Open

fix: export only default for opencode plugin loader compatibility#1
bhodgens wants to merge 1 commit intodeiviuds:mainfrom
bhodgens:fix/export-default-only

Conversation

@bhodgens
Copy link

Summary

OpenCode's Bun-based plugin loader fails to resolve the default export when the module has mixed named + default exports.

Problem

The plugin fails to load with:

TypeError: fn3 is not a function. (In 'fn3(input)', 'fn3' is an instance of Object)
    at <anonymous> (src/plugin/index.ts:90:28)

The built output currently exports the default alongside 12+ named exports:

export { DEFAULT_CONFIG, Mind, OpenCodeBrain, ..., plugin_default as default, ... };

Working plugins (e.g. oh-my-opencode) export only default:

export { src_default as default };

Fix

Changed src/index.ts to only re-export the default plugin function, matching the pattern used by working OpenCode plugins.

Testing

  • Verified the build output matches the working export pattern
  • Plugin loads successfully after the change

@gemini-code-assist
Copy link

Summary of Changes

Hello @bhodgens, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical compatibility issue with the OpenCode plugin loader by streamlining the module's export structure. By removing all named exports and exclusively providing a default export, the change ensures that the plugin can be correctly loaded and utilized within the OpenCode environment, preventing runtime errors related to module resolution.

Highlights

  • OpenCode Plugin Loader Compatibility: Resolved a TypeError in OpenCode's Bun-based plugin loader by ensuring the module exports only a default function, addressing an incompatibility with mixed named and default exports.
  • Export Simplification: Modified src/index.ts to remove all named exports, retaining only the default export from plugin.js to match the expected pattern for OpenCode plugins.
  • Verified Fix: Confirmed that the build output now matches the working export pattern and that the plugin loads successfully after the change.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/index.ts
    • Removed all named exports, including types, core functions, and utility functions.
    • Modified to export only the default plugin function from ./plugin.js.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


Summary by CodeRabbit

  • Refactor
    • Simplified the module's public API surface. The module now provides only the default plugin export; previously available type definitions, utility functions, and core APIs are no longer directly exported.

Walkthrough

The public API of the module is restructured to export only the default plugin export from plugin.js. All previously exported types, constants, and utilities—including OpenCodeBrain, type definitions, DEFAULT_CONFIG, and core APIs—are removed from the public interface, significantly reducing the exported surface area.

Changes

Cohort / File(s) Summary
API Surface Reduction
src/index.ts
Removed all named exports, type exports, and utility exports. Retained only export { default } from "./plugin.js". Previously exported: OpenCodeBrain, type definitions (Observation, MindConfig, MindStats, etc.), DEFAULT_CONFIG, core APIs (Mind, getMind, resetMind), and utilities (helpers, compression, lock).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: exporting only the default export for OpenCode plugin loader compatibility.
Description check ✅ Passed The description clearly explains the problem, the fix implemented, and testing done, all directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a compatibility issue with the OpenCode plugin loader by ensuring that the main entry point only has a default export. The change is simple and effective for its stated purpose. My review includes a suggestion to preserve the library's API by moving the removed named exports to a secondary entry point, which would prevent a breaking change for users who might be consuming this package as a library.

Comment on lines +8 to +9
// Plugin default export — must be the ONLY export for opencode plugin loader compatibility
export { default } from "./plugin.js"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change correctly fixes the plugin compatibility issue. However, it removes all named exports, which is a breaking change for any consumers using this package as a library.

To avoid this, you could move the removed exports to a secondary entry point, for example src/lib.ts. This would preserve the library API.

You would then need to configure package.json to expose this new entry point, allowing imports like import { Mind } from 'opencode-brain/lib'.

This approach maintains both plugin compatibility and the library's usability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant