Repository navigation
Closed
Description
Summary
graphify install --platform opencode writes a V1-format OpenCode plugin that OpenCode V2 refuses to load, and registers it in .opencode/opencode.json under the V1 plugin key, which V2 also rejects. The result is a failed server plugin load plus a spurious npm-install error.
Environment
- OpenCode
v2.0.12(Bun-compiled binary, background service) - graphify
0.9.65(latest on PyPI at the time of writing)
Observed
OpenCode server log (~/.local/share/opencode/log/opencode.log, role=server):
level=WARN message="failed to load plugin"
target=.../.opencode/plugins/graphify.js ref=err_...
cause="Cause([Fail(PluginModule.LoadError: Plugin must export a default definition
with an id and an effect or setup function. (cause: SchemaError(Missing key at ["default"])))])"
A second, separate failure comes from the config registration being treated as an npm package spec:
level=WARN message="failed to load plugin" target=.opencode/plugins/graphify.js
cause="Cause([Fail(NpmInstallFailedError (cause: Error: Could not read package.json:
ENOTDIR: not a directory, open '.../.opencode/plugins/graphify.js/package.json'))])"
Cause
- OpenCode V2 requires a plugin to default-export a definition with an
idand asetup(oreffect) function, and hooks are registered on their domain viactx.tool.hook("execute.before", ...). V1 plugin functions (named export returning a"tool.execute.before"object) no longer run. - V2 renamed the shell tool id from
bashtoshell. graphify/install.py::_OPENCODE_PLUGIN_JSis still the V1 shape._install_opencode_pluginregisters the file under the V1pluginkey using a bare relative path. V2 readsplugins, and a bare path is interpreted as an npm package, producing theNpmInstallFailedError.- V2 auto-discovers plugins under
.opencode/plugins/, so the config registration is unnecessary.
Suggested fix
- Emit a V2 default-export plugin. A plain object literal is sufficient;
Plugin.definefrom@opencode/pluginis not resolvable from a loose file under.opencode/plugins/(nonode_modules). - Drop the
opencode.jsonregistration (auto-discovery handles it), or move it topluginswith a resolvable path. - Accept both
shell(V2) andbash(V1) tool ids, and useevent.input.commandinstead ofoutput.args.command.
Reference port:
import { existsSync } from "fs";
import { join } from "path";
export default {
id: "graphify",
async setup(ctx) {
let reminded = false;
await ctx.tool.hook("execute.before", (event) => {
if (reminded) return;
if (!existsSync(join(ctx.location.directory, "graphify-out", "graph.json"))) return;
if (event.tool === "shell" || event.tool === "bash") {
event.input.command =
'echo "[graphify] ..." ; ' + event.input.command;
reminded = true;
}
});
},
};A local patch to install.py and tests/test_install.py is available on request.
Metadata
Metadata
Assignees
Labels
No labels
Activity
maroayman commentedon Oct 2, 2026
Still reproduces on newer versions, and the suggested reference port is verified working end-to-end.
Environment
0.9.74(uv tool install; original report was0.9.65— bug still ships)v2.0.22(background service, Linux)graphify install --platform opencodein a project, then a normal session startFresh log evidence
~/.local/share/opencode/log/opencode.log(role=server, run7caaa3e7, 2026-10-02):Additional detail vs. the original report: the bare relative spec resolved against
$HOME, not the project directory (project is/home/maro/Projects/deno, but the ENOENT path is/home/maro/.opencode/...). Worth checking the resolution base for thepluginkey as well as the key name itself.While the
pluginkey was present, we also saw repeated:Fix verification
Applied exactly the suggested fix from this issue:
{ id: "graphify", async setup(ctx) }), registering the hook viactx.tool.hook("execute.before", ...), accepting bothshellandbashtool ids, mutatingevent.input.command.pluginkey from.opencode/opencode.json(auto-discovery handles.opencode/plugins/).After
opencode service restart:INFO msg="loading plugin" id=/home/maro/Projects/deno/.opencode/plugins/graphify.jswith no failure following itfailed to load plugin/failed to check plugin updateentries in the new run[graphify] knowledge graph at graphify-out/...echo was prepended to the first shell command of the session, visible in the log's spawn line)Conclusion: the reference port in this issue works as-is; it just needs to land in
graphify/install.py::_OPENCODE_PLUGIN_JS, and_install_opencode_pluginshould drop theplugin-key registration. Note that any local patch is necessarily temporary — the nextgraphify installoverwrites it, so the upstream emit is the only durable fix.fix(opencode): load the plugin on OpenCode 2 and refresh installed co…
fix(opencode): load the plugin on OpenCode 2 and refresh installed co…
fix(opencode): load the plugin on OpenCode 2 and refresh installed co…
fix(opencode): emit dual v1+v2 plugin and register it with a file:// URI
fix(opencode): load the plugin on OpenCode 2 and refresh installed co…
safishamsi commentedon Oct 10, 2026
Fixed in 0.9.84 (now on PyPI). The installer now emits a dual v1+v2 plugin (default export with
setup()for OpenCode 2, plus the v1server()hook), andgraphify installrefreshes an already-installed v1-only copy that was failing to load. Landed via #4039 (thanks @bercedev). Thanks, @dyyptons.Merge upstream v8 into fix-2709-opencode-slash-command
Merge upstream v8 into fix 2709 opencode slash command