graphify icon indicating copy to clipboard operation
graphify copied to clipboard

OpenCode global install writes plugin and slash command to CWD instead of ~/.config/opencode/

Open ayushcodes10 opened this issue 2 months ago • 3 comments

Summary

Surfaced via automated review on #2727 (_install_opencode_command, adding the native /graphify slash command). A non-project (global, no --project) OpenCode install writes the plugin and the slash command to the current working directory's .opencode/ instead of the documented ~/.config/opencode/.

Where

Both _install_opencode_plugin and _install_opencode_command in graphify/install.py document the intended global location in their own docstrings:

OpenCode auto-loads every plugin file under .opencode/plugins/ (project) or ~/.config/opencode/plugins/ (global) at startup

Only a markdown file under .opencode/commands/ (or ~/.config/opencode/commands/ globally) becomes a /-menu entry

But every call site passes Path(".") for the non-project case instead of a ~/.config/opencode base:

_install_opencode_plugin(project_dir if project else Path("."))
_install_opencode_command(project_dir if project else Path("."))

_OPENCODE_PLUGIN_PATH/_OPENCODE_COMMAND_PATH also hardcode a leading .opencode/ segment, which is right for a project-relative install (<project_dir>/.opencode/plugins/graphify.js) but wrong for the global case (should be ~/.config/opencode/plugins/graphify.js, no extra .opencode/ nesting) — so this needs more than just swapping the base path.

This predates #2709/#2727; the slash command PR just inherited the same pattern from its sibling function for consistency, since fixing it there would have meant reworking both functions across their several call sites in install(), _agents_install, _agents_uninstall, and uninstall_all.

Fix

Likely needs _install_opencode_plugin/_install_opencode_command (and their uninstall counterparts) to take an explicit project: bool (or a pre-resolved base path) rather than always joining onto whatever project_dir they're handed, so the global case can correctly target ~/.config/opencode/ without the extra .opencode/ segment, matching how ~/.config/opencode/skills/graphify/SKILL.md is already resolved elsewhere in this file for the OpenCode skill itself.

ayushcodes10 avatar Sep 07 '26 12:09 ayushcodes10

Hey! I've opened a PR to fix this issue.

I updated _install_opencode_plugin and its uninstall counterpart to explicitly handle the project boolean, cleanly separating the global installation path (~/.config/opencode/) from the project-scoped path (<project_dir>/.opencode/).

I also added a suite of tests to verify the routing for both global and project installations, as well as the uninstaller, to ensure this doesn't regress. Let me know if any changes are needed!

nikhilsaxena04 avatar Sep 09 '26 22:09 nikhilsaxena04

Opened #4771. A global install now writes the plugin to ~/.config/opencode/plugins/graphify.js (no .opencode/ nesting), graphify uninstall removes it, and the OpenCode 2 auto-refresh checks that dir too. The slash-command half no longer applies on v8, because _install_opencode_command is gone, so this is plugin-only now. It takes the same approach as #3459 (@nikhilsaxena04), rebuilt on current v8 because that PR now conflicts. This closes when #4771 merges.

nothariharan avatar Oct 26 '26 01:10 nothariharan

Fixed in v0.9.99 via #4771 (pip install graphifyy==0.9.99). The global OpenCode install writes the plugin to ~/.config/opencode. Thanks for the report, @ayushcodes10.

safishamsi avatar Oct 30 '26 23:10 safishamsi