Skip to content

fix: plugin crashes on load — exports expose classes that OpenCode calls as functions#35

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-plugin-non-functional-issue
Closed

fix: plugin crashes on load — exports expose classes that OpenCode calls as functions#35
Copilot wants to merge 3 commits intomainfrom
copilot/fix-plugin-non-functional-issue

Conversation

Copy link

Copilot AI commented Feb 15, 2026

OpenCode's plugin loader iterates all module exports and calls each as fn(input). Our "import" export pointed to dist/index.js which re-exports utility classes (DeltaTracker, StreamToSseConverter, etc.). OpenCode calls DeltaTracker(input) without new → TypeError. Separately, opencode auth login didn't show cursor because the plugin-toggle only matched "cursor-acp" in the plugin array, not the npm package name "@rama_nigg/open-cursor@latest".

Package exports

  • "main" and exports["."] now resolve to dist/plugin-entry.js (single default export) instead of dist/index.js
  • Full library API preserved under "./lib" subpath for programmatic consumers

Plugin toggle

  • isCursorPluginEnabledInConfig now recognizes @rama_nigg/open-cursor with optional @version suffix, not just the legacy cursor-acp symlink name
// Both of these now work:
{ "plugin": ["cursor-acp"] }
{ "plugin": ["@rama_nigg/open-cursor@latest"] }

OpenCode loader reference

From anomalyco/opencode src/plugin/index.ts:

for (const [_name, fn] of Object.entries(mod)) {
  const init = await fn(input)  // calls every export as a plugin function
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • opencode.ai
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Plugin non-functional</issue_title>
<issue_description>```
$ opencode
{
"name": "UnknownError",
"data": {
"message": "TypeError: Cannot call a class constructor DeltaTracker without |new|\n at DeltaTracker (unknown:1:11)\n at (src/plugin/index.ts:90:28)\n at processTicksAndRejections (native:7:39)"
}
}


I tried installing via npm, via the TUI installer, and simply by editing opencode.json. Results are the same.

opencode auth login also doesn't display cursor option.</issue_description>

<agent_instructions>Let's investigate and solve this one, it's very concerning, suggests latest commits had errors.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 15, 2026 22:36
Co-authored-by: Nomadcxx <143774106+Nomadcxx@users.noreply.github.com>
…ations

Root cause: OpenCode's plugin loader iterates all module exports and calls
each as a plugin function. The package.json "import"/"default" exports
pointed to dist/index.js which exports utility classes (DeltaTracker, etc.)
alongside the plugin function. When OpenCode called DeltaTracker(input)
without new, it threw TypeError.

Fix 1 - package.json exports: Point "import" and "default" to
dist/plugin-entry.js (single default export) instead of dist/index.js.
Library consumers can use @rama_nigg/open-cursor/lib for full API.

Fix 2 - plugin-toggle: The toggle guard only recognized "cursor-acp" in
the plugin array, but npm users configure "@rama_nigg/open-cursor@latest".
Now recognizes both the legacy symlink name and the npm package name with
optional version suffix.

Co-authored-by: Nomadcxx <143774106+Nomadcxx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix plugin non-functional error in DeltaTracker fix: plugin crashes on load — exports expose classes that OpenCode calls as functions Feb 15, 2026
Copilot AI requested a review from Nomadcxx February 15, 2026 22:46
@Nomadcxx
Copy link
Owner

Closing in favor of PR #36 which contains the same fix.

@Nomadcxx Nomadcxx closed this Feb 15, 2026
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.

Plugin non-functional

2 participants