Skip to content

fix(opencode): write global-install plugin to ~/.config/opencode/ instead of cwd - #1414

Open
WSHAPER wants to merge 1 commit into
Graphify-Labs:v8from
WSHAPER:fix/opencode-global-install-path
Open

WSHAPER wants to merge 1 commit into
Graphify-Labs:v8from
WSHAPER:fix/opencode-global-install-path

Conversation

@WSHAPER

@WSHAPER WSHAPER commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1412.

Summary

Running graphify install --platform opencode without --project (the documented global-install mode) wrote the plugin to <cwd>/.opencode/plugins/graphify.js and created a stray <cwd>/.opencode/opencode.json. Neither file is loaded by opencode — opencode resolves .opencode/plugins/<name>.js entries relative to the declaring config's directory, and the global config lives at ~/.config/opencode/opencode.json, not cwd.

The installer log claimed success (tool.execute.before hook written, plugin registered), but the plugin silently never loaded. This is the global-mode sibling of #1040 (which was the --project variant of the same class of bug).

Root cause

graphify/__main__.py line 697 (v0.8.44):

if platform == "opencode":
    _install_opencode_plugin(project_dir if project else Path("."))

For global installs (project=False), this resolved the plugin destination against Path(".") — the current working directory. Run from ~, the plugin landed at ~/.opencode/plugins/graphify.js. Run from any other cwd, it landed wherever the user happened to be.

Meanwhile, the skill install path (line 148-151) already handled both modes correctly:

if platform_name == "opencode":
    if project:
        return (project_dir or Path(".")) / ".opencode" / "skills" / "graphify" / "SKILL.md"
    return Path.home() / ".config" / "opencode" / "skills" / "graphify" / "SKILL.md"

The plugin install path simply didn't have the same branching — it always used project_dir regardless of mode.

Fix

Thread project: bool = True into _install_opencode_plugin / _uninstall_opencode_plugin. When project=False, resolve base dir via Path.home() / ".config" / "opencode" (matching the existing skill-path logic, monkey-patchable in tests via Path.home). When project=True (default, used by _agents_install etc.), behaviour is unchanged.

Only the global-mode caller (install() at line 697) passes the new flag; the five other callers (_agents_install, _agents_uninstall × 3, uninstall_all) are project-scoped by design and use the default.

Also: the install/uninstall messages now print the resolved absolute path so users can see where the plugin actually landed (previously they saw the relative .opencode/plugins/graphify.js which gave no clue about which tree it was written to).

Verification

Three new regression tests:

  1. test_install_opencode_global_writes_plugin_to_config_dir — after global install, plugin exists at ~/.config/opencode/.opencode/plugins/graphify.js and there is no stray <cwd>/.opencode/ tree.
  2. test_install_opencode_global_registers_plugin_in_config — registration goes into ~/.config/opencode/.opencode/opencode.json, not a stray cwd-relative file.
  3. test_uninstall_opencode_global_removes_plugin — global uninstall (project=False) removes the plugin from the correct location.

All 12 opencode install tests pass; no regressions in the broader install/roundtrip/upgrade/reference suites (156 tests pass).

Workaround for users on already-released versions

mkdir -p ~/.config/opencode/.opencode/plugins
cp ~/.opencode/plugins/graphify.js ~/.config/opencode/.opencode/plugins/graphify.js
rm -rf ~/.opencode/plugins ~/.opencode/opencode.json

Related

…tead of cwd (Graphify-Labs#1412)

`graphify install --platform opencode` (without --project) previously
called `_install_opencode_plugin(Path("."))`, which resolved the plugin
destination against the current working directory. opencode resolves
`.opencode/plugins/<name>.js` entries relative to the declaring config's
directory — and the global config lives at `~/.config/opencode/opencode.json`,
not cwd. So the installer wrote:

  ~/.opencode/plugins/graphify.js   ← orphan (cwd happened to be ~)
  ~/.opencode/opencode.json         ← orphan config declaring the plugin

…neither of which opencode loads. The installer's "plugin registered"
message was false-positive in global mode.

Fix: thread `project: bool` into `_install_opencode_plugin` /
`_uninstall_opencode_plugin`. When False (global), resolve base dir
via `Path.home() / ".config" / "opencode"` — matching the existing
skill-path resolution that already worked correctly. When True
(default, used by `_agents_install` etc.), behaviour is unchanged.

The plugin FILE always lands at `<base>/.opencode/plugins/graphify.js`
(auto-discovered + relative-path-resolvable from the config). The CONFIG
REGISTRATION path differs by mode:
  - project mode: `<project>/.opencode/opencode.json` (one of three
    valid project-config paths opencode walks up from cwd to find)
  - global mode: `<base>/opencode.json` — i.e. `~/.config/opencode/opencode.json`,
    opencode's ONLY global config location. Writing it to
    `<base>/.opencode/opencode.json` (the obvious symmetric choice) is a
    silent no-op: that path is neither a project config nor the global config.

Messages now print the resolved absolute path so users can see where the
plugin actually landed.

Regression tests cover: plugin lands at
`~/.config/opencode/.opencode/plugins/graphify.js`, registration goes
into `~/.config/opencode/opencode.json` (with an explicit assertion that
no plugin entry leaks into a phantom `<base>/.opencode/opencode.json`),
and global uninstall removes both.
@WSHAPER
WSHAPER force-pushed the fix/opencode-global-install-path branch from 2b6a500 to c8e92ab Compare June 21, 2026 08:51

@safishamsi safishamsi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper rewrite is sound, but this doesn't fix the reported bug for the documented command. There are two opencode install entry points:

  • install() (graphify install --platform opencode) — patched here ✅
  • _agents_install() (graphify opencode install, dispatch ~__main__.py:2511) — not patched. It still calls _install_opencode_plugin(project_dir or Path(".")) with the default project=True, so graphify opencode install (no --project) still writes to <cwd>/.opencode/ — exactly #1412.

Please thread project= through the _agents_install call site, and the uninstall sites (~1710/1719/1738/1873) which still default to project-scope (a global uninstall won't clean ~/.config/opencode/). The added tests drive install() only — please add one driving _agents_install global so the primary command path is covered.

Note: #1415 edits the same region — whichever merges second will need a rebase.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: 'graphify install --platform opencode' (global, no --project) writes plugin to ~/.opencode/ instead of ~/.config/opencode/.opencode/plugins/

2 participants