Summary
/opencode:setup --enable-review-gate may write config to a different state directory than the Stop hook reads from, depending on whether CLAUDE_PLUGIN_DATA is present in the execution environment.
This can make setup appear successful while the Stop hook still sees the default disabled state.
Local evidence
plugins/opencode/scripts/lib/state.mjs selects the state root as:
process.env.CLAUDE_PLUGIN_DATA
? path.join(process.env.CLAUDE_PLUGIN_DATA, "state")
: path.join("/tmp", "opencode-companion")
setup is run through a Bash command from plugins/opencode/commands/setup.md. Hooks are run through Claude Code's hook system from plugins/opencode/hooks/hooks.json. Those two paths may not receive the same environment.
Expected behavior
Review gate state should be read and written from the same persistent location across setup commands, lifecycle hooks, and Stop hooks.
Suggested fix
Options:
- Make setup resolve the same persistent plugin-data path hooks use, even when
CLAUDE_PLUGIN_DATA is absent.
- Have the setup command explicitly pass/derive
CLAUDE_PLUGIN_DATA before invoking Node.
- As a compatibility bridge, write review-gate config to both the persistent state root and the legacy
/tmp/opencode-companion fallback.
Add a regression test that simulates setup with no CLAUDE_PLUGIN_DATA and hook execution with CLAUDE_PLUGIN_DATA set.
Upstream reference
Derived from openai/codex-plugin-cc#59.
Summary
/opencode:setup --enable-review-gatemay write config to a different state directory than the Stop hook reads from, depending on whetherCLAUDE_PLUGIN_DATAis present in the execution environment.This can make setup appear successful while the Stop hook still sees the default disabled state.
Local evidence
plugins/opencode/scripts/lib/state.mjsselects the state root as:setupis run through a Bash command fromplugins/opencode/commands/setup.md. Hooks are run through Claude Code's hook system fromplugins/opencode/hooks/hooks.json. Those two paths may not receive the same environment.Expected behavior
Review gate state should be read and written from the same persistent location across setup commands, lifecycle hooks, and Stop hooks.
Suggested fix
Options:
CLAUDE_PLUGIN_DATAis absent.CLAUDE_PLUGIN_DATAbefore invoking Node./tmp/opencode-companionfallback.Add a regression test that simulates setup with no
CLAUDE_PLUGIN_DATAand hook execution withCLAUDE_PLUGIN_DATAset.Upstream reference
Derived from openai/codex-plugin-cc#59.