Repository navigation
fix(load): a missing dependency names itself, not the default export - #465
Conversation
A loose copy under <config>/plugins/<name>/ installs nothing, so the eager zod import at src/tools/schema.ts:17 throws while the entry module is being evaluated. The host reports that as "Plugin must export a default definition with an id and an effect or setup function", which points at an export that is correct: src/index.ts:395 exports the V2 definition and index.ts re-exports it as default. A reader audits the wrong file instead of running the command that fixes it. The root shim now imports src/index.ts inside a try and, when that fails, still hands the host a valid definition with the literal id, and logs the package it could not resolve, the directory it was loaded from, and both fixes: bun install in that directory, or opencode plugin add. The id is a literal because it has to be right in exactly the case where src/index.ts never evaluated. test/host/plugin-shim.test.ts evaluates the shipped shim in a temp directory with no node_modules, so it proves both that the shim needs nothing installed and that the log names the cause. Docs gain the error string: a row in troubleshooting.md, a loose-copy section in install.md, and the README notes. Refs #464
b1086c3 to
616d4dc
Compare
WhollyMindless
left a comment
There was a problem hiding this comment.
Verified 616d4dc on native Windows with OpenCode 2.3.2. I put the shipped files under a fresh project's .opencode/plugins/self-improving-skills/ with no node_modules and started opencode run --standalone --print-logs. Loose discovery reached the real entry. The log named the copied directory and the missing zod import in src/tools/schema.ts, printed both install remedies, and reported that no tools or hooks were active. With the same setup on main (9e7c88d), I saw the host's load warning with zod in its underlying cause, without the plugin's remediation. This verifies the CLI diagnostic on Windows; I didn't exercise the desktop error display.
|
I checked the Windows OpenCode Desktop 2.3.2 project settings with two fresh Git projects and loose plugin copies, both missing their dependencies. Under Project → Extensions → Plugins, main ( The new diagnostic is useful in the host log. Someone looking only at Desktop can still see the plugin listed while its tools are unavailable. A short troubleshooting note pointing Desktop users from that panel to the host log would help. I couldn't reproduce the reporter's exact “Server plugin error” screen here. |
A review on this PR checked the desktop app and found the plugin panel lists the plugin under "Added to this project" and shows neither the missing package nor the install command — on main it lists the loose directory path instead, which is no better. The panel is therefore not where a desktop reader learns the cause, so the two places that mention the log have to say how to open it. `opencode run --standalone --print-logs` is the verified route: it printed the copied directory, the unresolved `zod` import and both fixes on a Windows checkout with no node_modules.
|
Both reports are useful, and the second one changes the docs. The desktop panel result is the important one. On this head the panel swaps a loose directory path for the plugin's own id, which is a real improvement — it is the difference between "some folder was picked up" and "this plugin loaded far enough to identify itself" — but neither version tells the reader a dependency is missing. So the panel is not where the fix gets across, and the two places in these docs that pointed at "the host log" never said how to open it. That was a dead end for exactly the reader whose panel shows nothing. Both rows now name the verified route: No code change: the shim already logs the package, the directory and both fixes, which is what your CLI run on Windows captured. — identified as an AI Assistant |
WhollyMindless
left a comment
There was a problem hiding this comment.
One copy-paste correction for the two new docs examples in 70a6cb7. I ran opencode run --standalone --print-logs as written in the affected project on Windows with OpenCode 2.3.2 and empty stdin. It exited 1 with You must provide a message before printing the plugin diagnostic. In the same fixture, opencode run --standalone --print-logs "diagnostic" printed the missing zod package, the loose-copy directory, and both install remedies. Adding the message argument in both places would give readers the working command. My earlier review abbreviated the invocation and omitted that argument.
`opencode run` requires a message. With none it exits with "You must provide a message" before any plugin is loaded, so the diagnostic the row exists to point at never prints. Reproduced on 2.3.0 and reported on 2.3.2 Windows. install.md gains a fenced command so the whole invocation is copy-pasteable.
|
Confirmed on this machine too, and fixed in v2.3.0, macOS. The server starts, the error lands, and the plugin is never loaded — so the row pointed readers at a command that cannot print the thing the row is about. Both places now carry — identified as an AI Assistant |
There was a problem hiding this comment.
Approving 07f3e65.
Both review rounds on this PR were corrections to my own work and both were right. The desktop panel shows neither the missing package nor the fix on main or on this head, so pointing readers at "the host log" without saying how to open it was a dead end for exactly that reader; and the command I then added does not run — opencode run needs a message, and without one it stops with You must provide a message before any plugin loads. I reproduced that here on 2.3.0, so it is not version-specific.
The docs now carry a copy-pasteable opencode run --standalone --print-logs "diagnostic" in both places, quote the failure string, and say the desktop plugin panel reports nothing about the dependency. Wording is limited to what the two Windows reports and this machine actually establish — no invented desktop log path.
The shim itself needed no change across either round: it already hands the host a valid definition with the literal id and logs the unresolved package, the directory it loaded from, and both fixes.
Gate green locally and on CI at this head: lint, test, test-windows, smoke.
— identified as an AI Assistant
|
🎉 This PR is included in version 0.33.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
One detail for the next docs edit now that our #459 is in the release. I ran the documented command on Windows OpenCode 2.3.2 against a fresh loose copy of the merged head ( |
What breaks
A user installs by dropping the plugin into
<config>/plugins/<name>/. Loosediscovery reads
<config>/plugins/<name>/index.tsand installs nothing, so thecopied directory has no
node_modules. The eagerzodimport atsrc/tools/schema.ts:17then throws while the entry module is being evaluated,and the host reports:
That names an export that is not wrong —
src/index.ts:395exports the V2definition object and
index.tsre-exports it asdefault. The reader audits acorrect file instead of running the command that fixes it.
Reproduced by copying the shipped file set to a directory with no
node_modules:@babel/parser, the other runtime dependency, survives the same situationbecause it is a lazy guarded
requireatsrc/recall/conflicts.ts:73. Zod isthe only eager one.
What this changes
index.tsimportssrc/index.tsinside atry. On failure it still hands thehost a valid definition — the literal
idplus asetupthat says nothing isactive — and logs the package it could not resolve, the directory it was loaded
from, and both fixes. The
idis a literal rather thanPLUGIN_IDbecause ithas to be correct in exactly the case where
src/index.tsnever evaluated, andthe host keys storage, status and diagnostics on it.
The directory belongs in the line for the same reason
plugin_loadcarriesentry=: a machine that has ever pointed apluginsentry at a checkout hastwo copies of this plugin.
Docs gain the error string, which they did not have: a row in
docs/reference/troubleshooting.md, a loose-copy section indocs/reference/install.md, and the README notes in Layout and thetroubleshooting index.
Tests
test/host/plugin-shim.test.tscopies the shippedindex.tsinto a tempdirectory with no
node_modulesand evaluates it. It asserts the failure pathyields
id+setup, that the log names the package, the directory and bothfixes, that
setupon the unloaded definition says nothing is active, and thata healthy
src/index.tspasses through with no diagnostic. Copying the realfile rather than importing it keeps the fixture honest about what a loose copy
actually is, and proves the shim itself needs nothing installed.
Merge gate green: 1603 pass / 21 skip / 0 fail unit, 37 pass e2e against a real
opencode host,
tscclean,biomeclean, comment-lint clean.Not in this PR
The load still fails without
node_modules— this makes the failure legible,not survivable. Reported in #464, which stays open for that decision: this PR
covers its entry-guard and documentation items, not the dependency removal.
Removing
zodfrom the plugin load path so a loose copy workswith zero runtime dependencies is the real fix and needs a decision: vendor a
bundled build, or hand-roll the bounded surface (
object,string,enum,array,boolean,coerce.number,optional,max,describe,iso.datetime, plusz.toJSONSchemaatsrc/tools/schema.ts:271andsafeParseat:306). The risk to pin is drift in thesafeParsemessage textthe model reads back. Tracked in #464.
Authored by an AI Assistant on behalf of the maintainer.