feat: add OpenCode user-level plugin to install command#198
feat: add OpenCode user-level plugin to install command#198imkarrer wants to merge 4 commits intotirth8205:mainfrom
Conversation
Install a TypeScript plugin (~/.config/opencode/plugins/crg-plugin.ts) that mirrors the three Claude Code hook behaviors: 1. file.edited: auto-update graph via code-review-graph update --skip-flows 2. session.created: show graph status via code-review-graph status 3. tool.execute.before: detect changes before git commit commands The plugin uses Bun's shell API and fails gracefully with try/catch since it's user-level and runs for all projects. Installed when running install/init with --platform opencode or --platform all, unless --no-hooks is passed. New functions in skills.py: - _opencode_plugin_content(): returns TypeScript plugin source - install_opencode_plugin(): writes plugin file, creates directories 16 new tests covering plugin content, event handlers, installation, idempotency, and file integrity.
Use PLATFORMS['opencode']['detect']() guard for consistency with MCP config install behavior. Currently detect() always returns True for OpenCode, but this ensures the pattern stays consistent if that changes.
|
The OpenCode plugin is well-implemented. The TypeScript plugin correctly hooks into The branch has merge conflicts with Once rebased, this is ready to merge. |
# Conflicts: # code_review_graph/cli.py
|
Skipping auto-merge: after #142 (platform target filters) landed on |
# Conflicts: # code_review_graph/cli.py # code_review_graph/skills.py
Summary
~/.config/opencode/plugins/crg-plugin.ts) that mirrors all three Claude Code hook behaviors: auto-update graph after file edits, show graph status on session start, and detect changes before git commits$shell API and fails gracefully with try/catch since it's user-level and runs for all projectsinstall/initwith--platform opencodeor--platform all, unless--no-hooksis passedRelated Issues & PRs
~/.config/opencode/plugins/) which should resolve the OpenCode side of that report--platformfiltering for hooks/skills; this PR respects the sametargetfiltering pattern for the OpenCode pluginChanges
code_review_graph/skills.py_opencode_plugin_content()— returns TypeScript plugin source as a string, hooking intofile.edited,session.created, andtool.execute.beforeeventsinstall_opencode_plugin()— writes~/.config/opencode/plugins/crg-plugin.ts, creating directories as neededcode_review_graph/cli.pyinstall_opencode_plugin()in_handle_init()when target isalloropencode, gated by--no-hooksloggermodule-level variable for consistent loggingtests/test_skills.pyTestOpenCodePluginContent(8 tests): plugin content validation, event hooks, try/catch coverage, TypeScript structureTestInstallOpenCodePlugin(8 tests): file creation, directory creation, overwrite behavior, idempotency, file integrityPlugin Behaviors
file.editedcode-review-graph update --skip-flowssession.createdcode-review-graph statusand logs outputtool.execute.before(when command matchesgit commit)code-review-graph detect-changes --briefand logs outputTesting
All 45 tests pass (29 existing + 16 new). Ruff and mypy clean.
Checklist (per CONTRIBUTING.md)
feature/opencode-pluginuv run pytest tests/test_skills.py(45/45)ruff checkwith rules E, F, I, N, Wmypy --ignore-missing-imports --no-strict-optional