Generate Conventional Commit messages using OpenCode CLI. Adds a button to the Source Control panel that instructs OpenCode to analyze your Git repository and auto-fills the commit message input box.
- You click Generate Commit Message in the Source Control panel
- The extension detects whether you have staged or unstaged changes
- OpenCode CLI runs inside your project directory with a prompt instructing it to analyze the repository
- OpenCode (an AI agent) inspects the Git diff, staged files, and changes on its own
- The generated Conventional Commit message is inserted into the SCM input box
- You review, edit, and commit as usual
No diff content is ever passed as a CLI argument — OpenCode runs directly in your repo and has full access to analyze it.
- One-click commit message generation — Button in the Source Control panel
- Conventional Commits — Messages follow the
feat:,fix:,chore:, etc. format - Smart change detection — Uses staged changes when available; falls back to unstaged
- Customizable prompt — Configure the instruction sent to OpenCode (
{changes}placeholder for "staged" or "unstaged") - Configurable timeout — Set max wait time for message generation (default 60s)
- Non-blocking — Async with progress indicator and cancellation support
- Safe — Never overwrites existing messages without confirmation; never commits automatically
- No external API calls — Everything runs through your local OpenCode CLI
- Works offline — Zero network dependencies
- VS Code 1.85+ or VS Codium
- OpenCode CLI installed and available in your PATH (or configured via settings)
- Git repository open in VS Code
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X) - Search for "OpenCode Commit Message"
- Click Install
- Download the
.vsixfile from the releases page - In VS Code, go to Extensions >
...> Install from VSIX... - Select the downloaded file
git clone https://github.com/vitormcampos/vscode-opencode-generate-commit-message.git
cd vscode-opencode-generate-commit-message
npm install
npm run compile
code --extensionDevelopmentPath=.Access settings via Ctrl+, (or Cmd+, on macOS) and search for "OpenCode Commit".
| Setting | Type | Default | Description |
|---|---|---|---|
opencodeCommit.opencode.path |
string |
"opencode" |
Path or command name for the OpenCode CLI executable. If OpenCode is in your PATH, the default works. Otherwise, set the full path (e.g., /usr/local/bin/opencode). |
opencodeCommit.opencode.prompt |
string |
(see below) | Prompt template sent to OpenCode. Use {changes} for "staged"/"unstaged". {diff} is also supported for backward compatibility. |
opencodeCommit.opencode.timeout |
number |
60000 |
Maximum time (ms) to wait for OpenCode CLI to respond. Range: 5000–300000. |
Analyze the {changes} changes in this Git repository and generate a concise commit
message. Use the Conventional Commits format (e.g., feat:, fix:, chore:, docs:,
refactor:, style:, test:, perf:). Write the message in English. Keep the subject
line under 72 characters. Return ONLY the commit message, no explanations, no
markdown formatting.
The {changes} placeholder is replaced with "staged" or "unstaged" depending on what the extension detected. OpenCode runs inside the project directory and analyzes the repository directly — it does not need the diff to be passed to it.
- Open the Source Control panel (
Ctrl+Shift+G/Cmd+Shift+G) - Make changes to your repository (and optionally stage them with
git add) - Click the Generate Commit Message button (sparkle icon) in the Source Control view header or repository header
- OpenCode analyzes the repository and generates a message
- The generated message is inserted into the commit message input box
- Review, edit if needed, and commit as usual
- Staged changes take priority. If you have staged files, the prompt says "staged" and OpenCode looks at staged changes
- No staged changes? The prompt says "unstaged" and OpenCode analyzes the working tree
- No changes at all? You'll see a notification — nothing to generate
- Existing message? You'll be prompted before overwriting (with "Yes" / "No" buttons)
| Issue | What happens |
|---|---|
| OpenCode CLI not found | Error message with instructions to configure opencodeCommit.opencode.path |
| No Git repository | Command hidden from UI; error shown if triggered via command palette |
| No changes detected | Informational message |
| OpenCode times out | Error message with suggestion to increase opencodeCommit.opencode.timeout |
| OpenCode returns empty | Warning message; existing input box content is preserved |
| Operation cancelled | Clean abort — no changes to the input box |
User clicks button
│
▼
┌─────────────────┐
│ extension.ts │ Reads config, validates opencodePath,
│ (orchestrator) │ gets Git repo, checks staged/unstaged
└────────┬────────┘
│
▼
┌─────────────────┐
│ opencodeRunner │ spawn('opencode', ['run', prompt],
│ .run() │ { cwd: repoRoot })
└────────┬────────┘
│
▼
┌─────────────────┐
│ OpenCode CLI │ Runs inside the project directory.
│ (AI agent) │ Inspects git diff, files, and changes
│ │ independently using its own tools.
└────────┬────────┘
│
▼
┌─────────────────┐
│ extension.ts │ Parses the response, sets repo.inputBox.value
└─────────────────┘
src/
├── extension.ts # Entry point: activate, command registration, orchestration
├── config.ts # Reads extension settings (path, prompt, timeout)
├── outputChannel.ts # Singleton OutputChannel for logging
├── gitService.ts # Wraps the VS Code Git Extension API
├── opencodeRunner.ts # Executes OpenCode CLI via child_process
└── test/
├── runTest.ts # VS Code test runner bootstrap
└── suite/
├── index.ts # Mocha test loader
└── extension.test.ts # Unit tests
# Clone and setup
git clone https://github.com/vitormcampos/vscode-opencode-generate-commit-message.git
cd vscode-opencode-generate-commit-message
npm install
# Compile
npm run compile
# Watch mode (auto-compile on save)
npm run watch
# Run tests
npm test
# Launch extension in VS Code dev mode
code --extensionDevelopmentPath=.# Package the extension
npx vsce package
# Publish to VS Code Marketplace
npx vsce publish
# Publish to Open VSX
npx ovsx publish