Caper Bush is an Oh My Zsh plugin that enhances Git's tab autocomplete by using AI to generate concise, context-aware summaries of staged changes for thoughtful commit messages.
Once installed, Caper Bush integrates directly with Git's autocomplete for the git commit -m
command. Simply
press <Tab>
after typing git commit -m
to:
- Analyze the staged changes in your repository.
- Receive AI-generated suggestions for concise and context-aware commit messages.
- Select a commit message from the dropdown or manually edit one.
This plugin requires the following tools to function properly:
jq
: For parsing JSON responses.yq
: For working with YAML configuration files.
brew install jq
brew install yq
Clone the repository into your custom Oh My Zsh plugins directory:
git clone https://github.com/kobylinski/caper-bush ~/.oh-my-zsh/custom/plugins/caper-bush
Edit your .zshrc
file and add caper-bush to the list of enabled plugins:
plugins=(... caper-bush)
Reload your Zsh configuration:
source ~/.zshrc
To set up Caper Bush, you need to configure your OpenAI API key and assistant in the OpenAI console. This step ensures that the plugin can generate commit messages tailored to your project.
- Log in to your OpenAI account at https://platform.openai.com/.
- Navigate to the API Keys section in your account settings.
- Click Create API Key and copy the generated key.
- Keep the key secure, as it will be required in your project-specific configuration file.
- Navigate to the Assistants section in the OpenAI console.
- Click Create Assistant and give it a meaningful name, such as Caper Bush Commit Assistant.
- In the System Instructions field, provide the following configuration to ensure proper functionality:
Analyze the staged changes provided as a diff and create the most accurate commit messages as a programmer reviewing the code. Use no more than 15 words per message. Use conventional commit prefixes including: feat: A new feature; fix: A bug fix; docs: Documentation changes; style: Code style changes; refactor: Code refactoring; perf: Performance improvements; test: Adding or updating tests; build: Changes to the build system; ci: Changes to CI/CD; chore: Minor updates; revert: Reverting a commit; config: Configuration changes; hotfix: Critical fixes only if commit looks like fix but the branch is main or master; deps: Dependency updates; db: Database changes; prototype: Experimental work. Your response will be handled by the application, so it should have a consistent format. Don't explain. In the case of more extensive changes, propose 2 to 6 messages. Don't use new line characters in or between messages. Use the pipe `|` character to separate messages. Provide the output as raw text. Example answer: `feat: add new authentication feature|fix: resolve login page bug|docs: update API documentation`
- Save the assistant configuration and note down the Assistant ID displayed in the console.
- In the root directory of your Git project, create a .caper-bush.yml file if it doesn’t already exist:
touch .caper-bush.yml
- Open
.caper-bush.yml
and add your OpenAI API key, Assistant ID, and any project-specific context or rules:
api_key: "your-openai-api-key"
assistant_id: "your-assistant-id"
# Project specific description to adjust asistant answers
# this text will be attached to the message requests
# for example:
about: "Ignore changes in docs directory."
- Ensure your
.caper-bush.yml
file is present in the root of your Git repository. - Test the setup by running:
git commit -m "<TAB>
- After the first usage, check your .caper-bush.yml file to verify that the thread_id field has been automatically added. Each repository will have its own dedicated thread for AI interactions, stored in this field:
thread_id: "project-dedicated-thread-id"
- If everything is configured correctly, the plugin will generate and display commit message suggestions based on your staged changes.
- Once the thread_id is present, the plugin will reuse this thread for subsequent interactions in the same repository.
This project is licensed under the MIT License. See the LICENSE file for details.