@@ -16,7 +16,8 @@ CONTENTS *codecompanion-gitcommit-contents*
16165. Commands | codecompanion-gitcommit-commands |
17176. Git Tools | codecompanion-gitcommit-git-tools |
18187. Configuration | codecompanion-gitcommit-config |
19- 8. License | codecompanion-gitcommit-license |
19+ 8. Programmatic API | codecompanion-gitcommit-api |
20+ 9. License | codecompanion-gitcommit-license |
2021
2122==============================================================================
22231. INTRODUCTION *codecompanion-gitcommit-intro*
@@ -41,6 +42,7 @@ chat buffers.
4142• Multi-language support for commit messages
4243• Support for regular commits and amend commits
4344• Smart diff analysis with file filtering capabilities
45+ • Commit history context for consistent styling and patterns
4446
4547🛠️ Git Tool Integration
4648• @git_read tool - 15 read-only Git operations (status, log, diff, etc.)
@@ -271,8 +273,68 @@ Buffer configuration:
271273*buffer.skip_auto_generate_on_amend* Type: boolean, Default: true
272274 Skip auto-generation during git commit --amend operations.
273275
276+ *use_commit_history* Type: boolean, Default: true
277+ When enabled, includes recent commit messages as context for the AI
278+ to maintain consistency in commit style and patterns.
279+
280+ *commit_history_count* Type: number, Default: 10
281+ Number of recent commits to include as context when use_commit_history
282+ is enabled.
283+
284+ ==============================================================================
285+ 8. PROGRAMMATIC API *codecompanion-gitcommit-api*
286+
287+ The extension provides a programmatic API for external integrations:
288+
289+ *gitcommit.exports.generate(lang, callback)*
290+ Generate commit message programmatically
291+ Parameters:
292+ • lang (string|nil): Language to generate commit message in (optional)
293+ • callback (function): Callback function with signature (result, error)
294+
295+ *gitcommit.exports.is_git_repo()*
296+ Check if current directory is in a git repository
297+ Returns: boolean
298+
299+ *gitcommit.exports.get_staged_diff()*
300+ Get staged changes diff
301+ Returns: string|nil
302+
303+ *gitcommit.exports.commit_changes(message)*
304+ Commit changes with provided message
305+ Parameters:
306+ • message (string): Commit message
307+ Returns: boolean
308+
309+ *gitcommit.exports.git_tool*
310+ Access to git tool functions including status, log, diff, branches,
311+ stage, unstage, create_branch, checkout, stash operations, reset,
312+ contributors, search_commits, merge, and more.
313+
314+ Example usage: >
315+ local gitcommit = require("codecompanion._extensions.gitcommit")
316+
317+ -- Generate commit message
318+ gitcommit.exports.generate("English", function(result, error)
319+ if result then
320+ print("Generated:", result)
321+ else
322+ print("Error:", error)
323+ end
324+ end)
325+
326+ -- Check if in git repo
327+ if gitcommit.exports.is_git_repo() then
328+ print("In git repository")
329+ end
330+
331+ -- Get git status
332+ local status = gitcommit.exports.git_tool.status()
333+ print("Git status:", status)
334+ <
335+
274336==============================================================================
275- 8 . LICENSE *codecompanion-gitcommit-license*
337+ 9 . LICENSE *codecompanion-gitcommit-license*
276338
277339MIT License
278340
0 commit comments