Skip to content

Loose plugin copy fails with a misleading export error: zod is unresolvable without node_modules #464

Closed

Description

@abogartz

What the user reported

A user on Windows installed the plugin by placing it in the loose-discovery
directory and the host reported:

Server plugin error
Plugin: D:\Ellie3\.opencode\plugins\self-improving-skills
Status: failed
Runtime: server
Source: D:\Ellie3\.opencode\plugins\self-improving-skills
Error: Plugin must export a default definition with an id and an effect or setup function.

The reported error does not name the cause

The default export is correct. src/index.ts:395 exports the plain V2
definition object with id and setup, PLUGIN_ID is the literal
"opencode-self-improvement" at src/index.ts:109, and the root index.ts
re-exports it as default. Loose discovery reads
<config>/plugins/<name>/index.ts, which is exactly the shim that file exists
to satisfy.

The module never evaluates, so the host sees no default export and blames the
export. The evaluation failure is a missing runtime dependency:

  • src/index.ts:107 eagerly imports src/tools/schema.ts.
  • src/tools/schema.ts:17 does a value import of z from "zod".
  • Loose discovery copies files and installs nothing, so
    D:\Ellie3\.opencode\plugins\self-improving-skills has no node_modules and
    zod cannot be resolved from it.

@babel/parser, the other runtime dependency, survives the same situation
because it is a lazy guarded require at src/recall/conflicts.ts:73. Zod is
the only eager one, so zod is what kills the load.

Reproduction

Copy the shipped file set (index.ts, tui.ts, package.json,
tsconfig.json, src, command, vendor) into a directory with no
node_modules and resolve the entry:

$ bun build --target=bun index.ts
17 | import { type ZodTypeAny, z } from "zod";
                                       ^
error: Could not resolve: "zod". Maybe you need to "bun install"?
    at /private/tmp/loose/self-improving-skills/src/tools/schema.ts:17:36

Reproduced 2026-11-20 against the current main file set. The host surfaces
its generic export error for the same underlying resolution failure.

Workaround for the user

Either install through the package route, which resolves through
package.json exports and gets runtime dependencies from the npm plugin cache:

opencode plugin add opencode-self-improvement

or keep the loose directory and install dependencies inside it:

cd "D:\Ellie3\.opencode\plugins\self-improving-skills" && bun install

Proposed fixes

  1. Make the entry degrade with the true cause. Have index.ts import
    src/index.ts dynamically inside a try, and on failure default-export a
    definition whose setup logs the real error and the directory it failed in.
    A user then reads "cannot resolve zod in : run bun install here or
    install with opencode plugin add" instead of an export complaint that
    points at code that is not wrong.
  2. Remove zod from the plugin load path so a loose copy loads with zero
    runtime dependencies. zod is load-bearing in two places only:
    z.toJSONSchema at src/tools/schema.ts:271 and safeParse at
    src/tools/schema.ts:306, over a bounded surface (object, string,
    enum, array, boolean, coerce.number, optional, max, describe,
    iso.datetime). Either vendor a bundled build or hand-roll that surface.
    This is the larger change and needs a decision on vendoring versus
    replacing; error-text drift in safeParse messages is the risk to pin with
    tests.
  3. Document it. docs/reference/troubleshooting.md has no row for this
    error string. A user who greps our own docs for the message they pasted
    finds nothing.

Scope note

The string self-improving-skills appears nowhere in this repository or its
git history, so the directory name is the user's own or a third party's. The
diagnosis above is from the local reproduction, not from her host log. If she
copied something other than this package, the same failure shape still applies
to any loose copy of this plugin.


Authored by an AI Assistant on behalf of the maintainer.

Activity

  1. added
    bug
    severity:high
    on Nov 20, 2026
  2. abogartz commented on Nov 21, 2026

    @abogartz
    OwnerAuthor

    Verified fixed on main — closing.

    The load path now catches the failed import and names the cause instead of blaming the export. index.ts (root shim) wraps await import("./src/index.ts") in try/catch, logs the directory that failed, and prints:

    opencode-self-improvement: a loose copy under <config>/plugins/ needs its runtime dependencies — run bun installin that directory, or install the package withopencode plugin add opencode-self-improvement.

    It also exports a literal-id unloaded definition so the host still keys storage and diagnostics on opencode-self-improvement when the module never evaluated.

    Landed in PR #465 (616d4dc, fix(load): a missing dependency names itself, not the default export), merged 2026-11-20. Verified against origin/main @ c48aea6 (v0.33.7).

  3. added
    verified-on-main
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugseverity:highverified-on-main

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions