feat: add OpenCode plugin hook integration#145
Merged
Conversation
There was a problem hiding this comment.
3 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="cmd/fence/hooks_doc.go">
<violation number="1" location="cmd/fence/hooks_doc.go:60">
P3: The JSONC comment detector also flags trailing commas, so the comment-loss warning can fire for files that contain no comments.</violation>
</file>
<file name="cmd/fence/hooks_jsonc_edit.go">
<violation number="1" location="cmd/fence/hooks_jsonc_edit.go:102">
P2: Uninstall byte-edit removes only the first matching plugin entry, so duplicate plugin entries can leave OpenCode still configured after a successful uninstall.</violation>
</file>
<file name="docs/agents.md">
<violation number="1" location="docs/agents.md:136">
P3: Document both OpenCode config filenames here. The installer prefers an existing `opencode.jsonc` before `opencode.json`, so this line points readers only at the fallback file.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
fence --opencode-pre-tool-usehelper mode and correspondingfence hooks {print,install,uninstall} --opencodesubcommands. The companion plugin lives at https://github.com/Use-Tusk/opencode-fence and routes thebashtool'stool.execute.beforelifecycle through this helper, so multi-token denies (gh repo create,git push, etc.) get enforced for OpenCode's agent-issued shell calls - the case Fence's path-only runtime exec policy can't catch on macOS.See: #143
Changes
--opencode-pre-tool-usemode (hooks_opencode.go) speaks a flat JSON wire format the plugin decodes; reusesevaluateShellHookRequestfor the policy check.fence hooks install --opencodeedits~/.config/opencode/opencode.{jsonc,json}to add@use-tusk/opencode-fenceto theplugin: [...]array. Probes for an existing.jsoncfirst (matching OpenCode's load order) and falls back to.jsonwhen neither exists.tidwall/sjsonbyte-level edits when thepluginarray already exists; falls back to the structured re-marshal otherwise.--force/-yflag on install/uninstall to skip the y/N prompt that fires when the structured-rewrite path would strip JSONC comments.docs/agents.md: new OpenCode subsection under Hooks, plus the Claude/Cursor/OpenCode subsection headings.