Skip to content

feat(gitcommit): add commit history context for message generation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
945 changes: 0 additions & 945 deletions EXTENSION_DEVELOPMENT_GUIDE.md

This file was deleted.

80 changes: 0 additions & 80 deletions GEMINI.md

This file was deleted.

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A Neovim plugin extension for CodeCompanion that generates AI-powered Git commit
- 🌍 **Multi-language Support** - Generate commit messages in multiple languages
- 📝 **Smart Buffer Integration** - Auto-generate commit messages in gitcommit buffers with configurable keymaps
- 📋 **File Filtering** - Support glob patterns to exclude files from diff analysis
- 📚 **Commit History Context** - Use recent commit history to maintain consistent styling and patterns
- 🔌 **Programmatic API** - Full API for external integrations and custom workflows
- ⚡ **Async Operations** - Non-blocking Git operations with proper error handling

## 📦 Installation
Expand Down Expand Up @@ -53,6 +55,10 @@ require("codecompanion").setup({
git_tool_auto_submit_errors = false, -- Auto-submit errors to LLM
git_tool_auto_submit_success = true, -- Auto-submit success to LLM
gitcommit_select_count = 100, -- Number of commits shown in /gitcommit

-- Commit history context (optional)
use_commit_history = true, -- Enable commit history context
commit_history_count = 10, -- Number of recent commits for context
}
}
}
Expand Down Expand Up @@ -170,6 +176,8 @@ opts = {
gitcommit_select_count = 100, -- Commits shown in /gitcommit
git_tool_auto_submit_errors = false, -- Auto-submit errors to LLM
git_tool_auto_submit_success = true, -- Auto-submit success to LLM
use_commit_history = true, -- Enable commit history context
commit_history_count = 10, -- Number of recent commits for context
buffer = {
enabled = true, -- Enable buffer integration
keymap = "<leader>gc", -- Keymap
Expand All @@ -182,6 +190,38 @@ opts = {

</details>

## 🔌 Programmatic API

The extension provides a comprehensive API for external integrations:

```lua
local gitcommit = require("codecompanion._extensions.gitcommit")

-- Generate commit message programmatically
gitcommit.exports.generate("English", function(result, error)
if result then
print("Generated:", result)
else
print("Error:", error)
end
end)

-- Check if in git repository
if gitcommit.exports.is_git_repo() then
print("In git repository")
end

-- Get git status
local status = gitcommit.exports.git_tool.status()
print("Git status:", status)

-- Stage files
gitcommit.exports.git_tool.stage({"file1.txt", "file2.txt"})

-- Create and checkout branch
gitcommit.exports.git_tool.create_branch("feature/new-feature", true)
```

## 📚 Documentation

For detailed documentation, see: `:help codecompanion-gitcommit`
Expand Down
140 changes: 140 additions & 0 deletions codecompanion-workspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"name": "CodeCompanion GitCommit Extension",
"version": "1.0.0",
"system_prompt": "You are helping with a Neovim plugin that extends CodeCompanion to provide AI-powered Git commit message generation following Conventional Commits specification. The plugin integrates deeply with Git workflows and provides comprehensive tooling for repository management through LLM-powered chat interfaces.",
"vars": {
"project_name": "codecompanion-gitcommit.nvim",
"main_module": "codecompanion._extensions.gitcommit"
},
"groups": [
{
"name": "core_extension",
"system_prompt": "This group contains the core extension entry point and configuration. Focus on the main initialization logic, extension setup, command registration, and overall architecture of how the plugin integrates with CodeCompanion.",
"data": [
"main_init",
"extension_config",
"type_definitions"
]
},
{
"name": "git_operations",
"system_prompt": "This group handles all Git repository operations including diff analysis, commit execution, repository validation, and file filtering. Focus on Git command execution, repository state management, and the core Git integration logic.",
"data": [
"git_core",
"git_buffer_integration"
]
},
{
"name": "ai_generation",
"system_prompt": "This group manages the AI-powered commit message generation using LLM adapters. Focus on prompt engineering, LLM communication, response handling, and the generation workflow for creating Conventional Commits compliant messages.",
"data": [
"message_generator",
"language_selection"
]
},
{
"name": "user_interface",
"system_prompt": "This group handles user interaction components including buffer integration for gitcommit buffers, floating window displays, and user interface elements. Focus on user experience, interactive elements, and visual presentation.",
"data": [
"buffer_management",
"ui_components"
]
},
{
"name": "git_tools",
"system_prompt": "This group provides comprehensive Git tooling for CodeCompanion chat integration, including read-only operations, write operations, and the Git bot assistant. Focus on tool schemas, command execution, safety mechanisms, and chat integration.",
"data": [
"git_tools_core",
"git_read_tool",
"git_edit_tool"
]
},
{
"name": "documentation_and_examples",
"system_prompt": "This group contains project documentation, usage examples, and configuration templates. Focus on user guidance, feature documentation, and setup instructions.",
"data": [
"readme_docs",
"config_examples",
"help_documentation"
]
}
],
"data": {
"main_init": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/init.lua",
"description": "Main extension entry point with setup function, command registration, tool integration, and programmatic API exports"
},
"extension_config": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/config.lua",
"description": "Extension configuration management with default options and validation"
},
"type_definitions": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/types.lua",
"description": "TypeScript-style type annotations and interface definitions for the extension"
},
"git_core": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/git.lua",
"description": "Core Git operations including repository validation, diff analysis, commit execution, and file filtering logic"
},
"git_buffer_integration": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/buffer.lua",
"description": "Git commit buffer integration with automatic message generation and keymap setup"
},
"message_generator": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/generator.lua",
"description": "AI-powered commit message generation using CodeCompanion's LLM adapters with prompt engineering and response handling"
},
"language_selection": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/langs.lua",
"description": "Multi-language support for commit message generation with language selection UI"
},
"buffer_management": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/buffer.lua",
"description": "Git commit buffer integration and automatic commit message insertion"
},
"ui_components": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/ui.lua",
"description": "Floating window UI for displaying commit messages with interactive options (copy, commit, edit)"
},
"git_tools_core": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/tools/git.lua",
"description": "Core Git tool utilities and shared functionality for read/write operations"
},
"git_read_tool": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/tools/git_read.lua",
"description": "Read-only Git operations tool for CodeCompanion chat (status, log, diff, blame, etc.)"
},
"git_edit_tool": {
"type": "file",
"path": "lua/codecompanion/_extensions/gitcommit/tools/git_edit.lua",
"description": "Write-access Git operations tool for CodeCompanion chat (stage, commit, branch management, etc.)"
},
"readme_docs": {
"type": "file",
"path": "README.md",
"description": "Main project documentation with features, installation, usage, and API reference"
},
"config_examples": {
"type": "file",
"path": "config_example.lua",
"description": "Basic configuration example for the extension setup"
},
"help_documentation": {
"type": "file",
"path": "doc/codecompanion-gitcommit.txt",
"description": "Vim help documentation for the extension"
}
}
}
Loading