Small utility for suggesting git commit messages
This doesn't exist yet. But here are some ideas:
- Write in go because it's portable and easy to work with
- Pipe
git diff --cachedinto an LLM and ask a few questions. For each question, ask the LLM to give a confidence score. Decide what to do next based on the scores.
- Is it possible this change is about multiple topics?
- If so, would you recommend splitting it into multiple commits?
- What is this change about?
- Come up with a first draft of your commit message.
- Provide the last 10 commits
- Is this commit closely related to these previous commits?
- If so:
- Does this commit look like it should be squashed with the previous commit?
- Does this commit look like it should be squashed into an earlier commit?
- If it shouldn't be squashed, should we change the commit message based on the relationship to the previous commits?
- Provide output from a configured linter (optional)
- Look at these linter outputs. Do any of them look VERY important? Bias your answer toward saying "no".
- Do these linter outputs make you think we should change the commit message?
- Provide the source of the modified files
- Do you see anything in these files that strongly suggests you should change the commit message?
- Generate 5 options for the commit header
- User manually selects one of the 5
- Generate 5 options for the commit body
- User manually selects one of the 5
- Pipe the result into
git commit --edit -m
Config:
- LLM model (only support local, start with ollama then maybe add llama.cpp)
- Support two different models? A big and small one?
- Support using a second model to check the first model's work?
- Optional stages:
- Previous commits
- Linter
- Configure linter to use
- File contents
Toy example of how this might work as a shell one-liner:
git commit --edit -m "$(echo "Write a conventional git commit message for the following diff. Your message should include a summary line at most 80 characters long. Then, skip a line and include as many lines as explanation as you feel are appropriate. ONLY OUTPUT THE COMMIT MESSAGE. $(git diff --cached)" | aichat)"