Skip to content

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

Open

Description

@WSHAPER

Summary

Running graphify install --platform opencode without --project (i.e. the documented global-install mode) writes the plugin to ~/.opencode/plugins/graphify.js and creates a new ~/.opencode/opencode.json next to it. Neither file is loaded by opencode — opencode's global config lives at ~/.config/opencode/opencode.json, and plugins referenced as .opencode/plugins/<name>.js in that config are resolved relative to that config's directory (~/.config/opencode/.opencode/plugins/). The installer writes to the wrong tree.

The installer log claims success (tool.execute.before hook written, plugin registered), but the plugin silently never loads. The ~/.opencode/ directory opencode creates is the npm-style binary install dir (~/.opencode/bin/opencode, ~/.opencode/node_modules/), not a config dir.

This is the global-mode sibling of #1040 (which was the --project variant of the same class of bug).

Environment

Reproduction

cd ~
rm -rf .opencode/plugins/graphify.js .opencode/opencode.json \
       .config/opencode/.opencode/plugins/graphify.js
graphify install --platform opencode

Actual output

  references       ->  /home/ikv/.config/opencode/skills/graphify/references
  skill installed  ->  /home/ikv/.config/opencode/skills/graphify/SKILL.md
  .opencode/plugins/graphify.js  ->  tool.execute.before hook written
  .opencode/opencode.json  ->  plugin registered

Actual filesystem state after install

/home/ikv/.opencode/                                 ← npm-style binary install dir
├── bin/opencode
├── node_modules/
├── package.json
├── opencode.json                                   ← installer CREATED this (orphan)
│   (contents: {"$schema":"…","plugin":[".opencode/plugins/graphify.js"]})
└── plugins/
    └── graphify.js                                 ← installer wrote plugin HERE (orphan)

/home/ikv/.config/opencode/                         ← the REAL global config dir
├── opencode.json                                   ← user's actual config (untouched)
│   (already has "plugin": [".opencode/plugins/graphify.js"] from a prior install)
├── skills/graphify/SKILL.md                        ← correctly placed (skill DOES load)
└── .opencode/plugins/                              ← EMPTY — no graphify.js here

Observed symptom

The skill loads correctly, but the plugin never fires its tool.execute.before hook, because opencode resolves .opencode/plugins/graphify.js against ~/.config/opencode/ (where the loaded config lives), not against ~/.opencode/.

Running graphify query "<question>" confirms the skill is registered, but bash search commands (grep, rg, find) produce no reminder — the hook is dead.

Workaround

After install, manually move the plugin to where opencode actually loads it from:

mkdir -p ~/.config/opencode/.opencode/plugins
cp ~/.opencode/plugins/graphify.js ~/.config/opencode/.opencode/plugins/graphify.js
# Optional: delete the orphans
rm -rf ~/.opencode/plugins ~/.opencode/opencode.json

Expected behaviour

The installer should resolve the global opencode config dir via (in order of preference):

  1. $XDG_CONFIG_HOME/opencode if XDG_CONFIG_HOME is set
  2. ~/.config/opencode/ (the documented default — see https://opencode.ai/config.json and the customize-opencode skill shipped with opencode itself, which explicitly states: "Global config — ~/.config/opencode/opencode.json (NOT ~/.opencode/)")

…and write the plugin to <config_dir>/.opencode/plugins/graphify.js, registering it in <config_dir>/opencode.json only if not already present.

~/.opencode/ is opencode's binary/cache dir, not a config dir, and should not be touched by the installer.

Related

Suggested fix

In the installer code path for --platform opencode global mode, replace the destination resolution (pseudocode):

# Before (buggy)
config_dir = home / ".opencode"

# After (correct)
xdg = os.environ.get("XDG_CONFIG_HOME")
config_dir = Path(xdg) / "opencode" if xdg else home / ".config" / "opencode"

…and write graphify.js to config_dir / ".opencode" / "plugins" / "graphify.js". The skill write path (config_dir / "skills" / "graphify" / ...) already does this correctly — only the plugin + opencode.json writes are wrong.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions