@azatakmyradov/opencode-git-plugin
v0.2.0
Published
Interactive Git workflows and safety hooks for OpenCode V2
Downloads
258
Maintainers
Readme
@azatakmyradov/opencode-git-plugin
OpenCode V2 plugin that adds /commit, /new-branch, and /pr. An LLM writes the commit messages, branch names, and pull request text. The plugin runs the resulting git and gh commands and adds git safety hooks.
Install
Install the plugin from npm:
opencode2 plugin add @azatakmyradov/opencode-git-plugin
opencode2 plugin listThe server entrypoint enables the TUI entrypoint. An unversioned install starts with its cached version and checks npm for updates in the background. A downloaded update takes effect the next time the service starts. Restart it now with:
opencode2 service restartUse an exact package version for a reproducible install that does not update.
Workflows
/commit [notes...]reads the status, staged diff, and recent commit style to write a commit message, then commits. Onmainormaster, it asks whether to create a branch, commit anyway, or cancel. Unless you pass--staged, it also asks whether to stage all changes or commit only the staged changes./new-branch [notes...]uses the current work and existing branches to write a valid kebab-case branch name. It then creates and switches to that branch./pr [notes...]reads the branch diff to write a title and body and choose a base. It pushes the branch upstream and opens a GitHub pull request. Onmainormaster, it first offers to create a branch.
The slash menu and command palette list all three commands. While a command runs, OpenCode shows its progress and footer status, then reports the result in a toast. Press esc to stop generation and any running git or gh process.
Safety
- Rejects shell commands that contain
--no-verify, so they cannot bypass git hooks. - Sets
GIT_EDITOR=true,GIT_SEQUENCE_EDITOR=true, andGIT_MERGE_AUTOEDIT=nofor git shell commands. This stops an interactive editor from hanging the agent.
These hooks remain active when you are not using the interactive commands.
Options
| Option | Default | Description |
| ------------------ | -------------- | --------------------------------------------------------------------------------------------------- |
| model | Server default | Generation model in providerID/modelID[#variant] format. |
| headlessCommands | false | Register server versions of commit, new-branch, and pr for opencode run and remote clients. |
Headless commands do not show dialogs. They refuse actions that need an interactive decision. When they cannot ask which changes to stage, they stage all changes. They are disabled by default because their slash command names collide with the TUI commands.
Development
For local development, run bun install. Add packages/git/src/index.ts to opencode.jsonc and packages/git/src/tui.tsx to the global CLI plugin configuration. OpenCode cannot find the package-level ./tui export when it loads the server source file directly, so you must add both entries.
bun run --filter @azatakmyradov/opencode-git-plugin check
bun run --filter @azatakmyradov/opencode-git-plugin test
bun run check