[PR #275] feat: add OpenCode agent support #370

Closed
opened 2026-03-02 04:13:25 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/275

State: closed
Merged: Yes


Summary

Adds OpenCode agent support for git-ai, implementing issue #232.

Changes

  • src/commands/install_hooks.rs: Added check_opencode(), install_opencode_hooks(), and opencode_plugin_path() functions following existing patterns for Claude Code/Cursor
  • agent-support/opencode/git-ai.ts: New TypeScript plugin that integrates with OpenCode's plugin system

How it works

The plugin hooks into OpenCode's tool execution lifecycle:

  • chat.params - Captures the active model (supports mid-session model switches)
  • tool.execute.before - Creates human checkpoint before AI edits
  • tool.execute.after - Creates AI checkpoint after edits with model attribution

Key features:

  • Detects git repo from file path using git rev-parse --show-toplevel (works regardless of OpenCode's working directory)
  • Gracefully handles non-git directories and missing git-ai installation
  • Tracks edit and write tools

Testing

  • All 5 new OpenCode-specific unit tests pass
  • All 164 existing tests pass
  • Manually tested plugin with model switching (Claude Opus → Gemini → Claude Sonnet)

Installation

After merging, users can install with:

git-ai install-hooks

The plugin is installed to ~/.config/opencode/plugin/git-ai.ts

Closes #232

**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/275 **State:** closed **Merged:** Yes --- ## Summary Adds OpenCode agent support for git-ai, implementing issue #232. ## Changes - **`src/commands/install_hooks.rs`**: Added `check_opencode()`, `install_opencode_hooks()`, and `opencode_plugin_path()` functions following existing patterns for Claude Code/Cursor - **`agent-support/opencode/git-ai.ts`**: New TypeScript plugin that integrates with OpenCode's plugin system ## How it works The plugin hooks into OpenCode's tool execution lifecycle: - `chat.params` - Captures the active model (supports mid-session model switches) - `tool.execute.before` - Creates human checkpoint before AI edits - `tool.execute.after` - Creates AI checkpoint after edits with model attribution Key features: - Detects git repo from file path using `git rev-parse --show-toplevel` (works regardless of OpenCode's working directory) - Gracefully handles non-git directories and missing git-ai installation - Tracks `edit` and `write` tools ## Testing - All 5 new OpenCode-specific unit tests pass - All 164 existing tests pass - Manually tested plugin with model switching (Claude Opus → Gemini → Claude Sonnet) ## Installation After merging, users can install with: ```bash git-ai install-hooks ``` The plugin is installed to `~/.config/opencode/plugin/git-ai.ts` Closes #232
kerem 2026-03-02 04:13:25 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#370
No description provided.