Documentation
¶
Overview ¶
Package commitmsg implements AI-powered conventional commit message generation. It reads staged git changes and the active PM task, then asks the configured provider to produce a Conventional Commits spec message.
Git hook integration:
To use as a prepare-commit-msg hook, create .git/hooks/prepare-commit-msg:
#!/bin/sh
# Only run when there is no commit message yet (interactive commit)
case "$2" in
merge|squash) exit 0 ;;
esac
msg=$(cloop commit-msg 2>/dev/null)
if [ -n "$msg" ]; then
echo "$msg" > "$1"
fi
Make it executable: chmod +x .git/hooks/prepare-commit-msg
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
func BuildPrompt(c *CommitContext) string
BuildPrompt constructs the AI prompt from the commit context.
func CollectDiff ¶
CollectDiff runs `git diff --cached` in workDir and returns the output. If there are no staged changes the returned string is empty.
Types ¶
type CommitContext ¶
type CommitContext struct {
// StagedDiff is the output of `git diff --cached`.
StagedDiff string
// ActiveTask is the currently in-progress PM task, if any.
ActiveTask *pm.Task
// Goal is the project goal from state.
Goal string
// TypeOverride, when non-empty, forces a specific Conventional Commits type
// (e.g. "feat", "fix", "chore").
TypeOverride string
}
CommitContext holds the data used to generate a commit message.
Click to show internal directories.
Click to hide internal directories.