MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

External plugins ("plugin": [...]) — module code never executes

Open Cipher208 opened this issue 4 months ago • 0 comments

External plugins ("plugin": [...]) — module code never executes

Description

External plugins listed in mimocode.json under "plugin" array are discovered but their module code is never executed. The server factory function is never called, and no hooks are registered.

Steps to Reproduce

  1. Create a minimal plugin file:
// ~/.config/opencode/plugins/test-plugin.mjs
console.log("[test] MODULE IMPORTED")
export default async (input) => {
    console.log("[test] FACTORY CALLED")
    return {}
}
  1. Add to ~/.config/mimocode/mimocode.json:
{
  "plugin": ["/home/user/.config/opencode/plugins/test-plugin.mjs"]
}
  1. Restart MiMoCode

  2. Check logs — console.log output never appears:

# Expected:
INFO service=plugin path=.../test-plugin.mjs loaded plugin
[test] MODULE IMPORTED
[test] FACTORY CALLED

# Actual:
INFO service=plugin path=.../test-plugin.mjs loading plugin
(nothing else)

Expected Behavior

Module code executes:

  • Top-level console.log appears in logs
  • default export function (factory) is called
  • Returned hooks are registered

Actual Behavior

Module code never executes:

  • console.log never appears
  • Factory function is never called
  • No hooks are registered
  • Plugin shows as "loading" but never "loaded"

Environment

  • MiMoCode version: 0.38.9
  • Node.js: v22.22.2
  • OS: Ubuntu 24.04
  • File format: .mjs (ESM)

Comparison with File Hooks

File hooks (~/.config/mimocode/hooks/*.ts) work correctly:

  • Module code executes
  • console.log appears (via writeFileSync)
  • export default hooks are registered
  • tool.execute.before, tool.execute.after, session.userQuery.post all fire

What I've Tried

  1. Different export formats: export default fn, export default {server: fn}, named exports
  2. Different file extensions: .ts, .mjs, .js
  3. Different config paths: absolute path, npm package name
  4. Adding console.log at module top level — never appears
  5. Verified with import() in Node.js — module loads correctly

Theory

The "plugin" config entry is used for file discovery but the runtime loader never calls import() on the resolved path. File hooks (hooks/*.ts) use a different loader that does call import().

Request

Either:

  1. Fix the external plugin loader to actually import and execute plugin modules
  2. Or document that external plugins are not supported and remove them from config schema

Impact

Many plugins (oh-my-opencode-slim, opencode-plusplus, ponytail) use the "plugin" config and assume it works. Users waste hours debugging plugins that can never work.

Cipher208 avatar Jul 23 '26 21:07 Cipher208