CommitAI is an open-source framework for creating and managing AI agents through simple YAML configurations. It allows you to build custom AI assistants with various tools for tasks like code reviews, issue triaging, documentation updates, and more.
- 🛠️ Extensible Tool System: Easily add new tools and capabilities to your agents
- ⚙️ YAML-based Configuration: Define complex agent behaviors without writing code
- 🤖 Multiple Agent Types: Create specialized agents for different tasks
- 🔄 Git Integration: Built-in tools for working with Git repositories
- 🐳 Docker Support: Run agents in containers for easy deployment
- 🔌 OpenAI Integration: Leverage powerful language models for intelligent task execution
- Python 3.9+
- Git
- Docker (optional, for containerized execution)
OPENAI_API_KEYenvironment variable with a valid OpenAI API key
-
Clone the repository:
git clone https://github.com/zver-in/commitai.git cd commitai -
Install dependencies:
pip install -r requirements.txt
-
Set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
-
Install dependencies:
pip install -r requirements.txt
-
Set your API key (macOS / Linux):
export OPENAI_API_KEY="<your_api_key>"
For Windows (PowerShell):
setx OPENAI_API_KEY "<your_api_key>"Optionally set a default model via
OPENAI_MODEL.
You can also run this project using Docker, which is especially useful for consistent environments across different systems.
- Docker installed on your system
docker build -t commitai .Basic usage:
docker run -it --rm \
-e OPENAI_API_KEY=your_api_key_here \
-v $(pwd)/agents:/app/agents \
commitai --agent "/app/agents/assistant.yaml" "Your request here"For development with live code changes:
docker run -it --rm \
-e OPENAI_API_KEY=your_api_key_here \
-v $(pwd):/app \
-v /app/__pycache__ \
commitai --agent "/app/agents/assistant.yaml" "Your request here"- Mount your local
agentsdirectory to/app/agentsto use your agent configurations - Set
OPENAI_API_KEYenvironment variable for API authentication - Optionally set
OPENAI_MODELto specify a different model
- Create a new YAML file in the
agents/directory, for examplemy_agent.yaml:
id: my_agent
description: |
A helpful AI assistant that can interact with files and Git repositories.
tools:
- name: list_directory
type: filesystem
config:
workdir: .
- name: read_file
type: filesystem
config:
workdir: .
- name: git_diff
type: git
config:
workdir: .- Run your agent:
python -m src.run_agent --agent "agents/my_agent.yaml" "Your request here"Review pull requests and suggest improvements:
python -m src.run_agent --agent "agents/code_reviewer.yaml" "Review the latest changes in the pull request"Help keep documentation up to date:
python -m src.run_agent --agent "agents/documentation_assistant.yaml" "Update README with latest features"Help manage and prioritize GitHub issues:
python -m src.run_agent --agent "agents/issue_triage.yaml" "Categorize and prioritize new issues"OPENAI_API_KEY— requiredOPENAI_MODEL— optional (default:gpt-4o-mini)
Note: The --agent must point to a YAML file that exists at the specified path. Prefer an absolute path or $PWD/agents/<file>.yaml so CI and scripts resolve the file correctly.
- If you see an error that
openaiis not installed, ensure you ranpip install -r requirements.txt. - If you get an authorization error, verify
OPENAI_API_KEYis set in your current terminal session.
.
├── agents/ # YAML configuration files for different agents
├── src/
│ ├── tools/ # Tool implementations
│ │ ├── factory.py # Tool factory for creating tool instances
│ │ ├── filesystem.py # Filesystem operations
│ │ └── git.py # Git operations
│ ├── agent.py # Core agent implementation
│ ├── config.py # Configuration loading and helpers
│ └── run_agent.py # CLI entry point
├── .github/workflows/ # GitHub Actions workflows
├── Dockerfile # Container configuration
├── requirements.txt # Python dependencies
└── README.md # This file
list_directory- List contents of a directoryread_file- Read file contents with support for line ranges and size limitswrite_file- Write to a fileview_file- View file contents with syntax highlightingsearch_in_files- Search for text within files under a given directory
git_changed_files- List files with uncommitted changes in the working directorygit_diff- Show uncommitted changes in the working directorygit_pr_diff- Show changes between the current branch and a base branch (typically 'main' or 'master')git_pr_changed_files- List files changed in a pull request compared to the base branch
post_review_comment- Post a code review comment to a GitHub Pull Requestlist_review_comments- List all review comments for the current Pull Request
We're actively working on expanding our Git toolset. Here are some of the features we plan to add:
- Branch management (create, switch, delete)
- Commit operations (commit, amend, revert)
- Remote repository interactions (push, pull, fetch)
- Tag management
- Stash operations
Stay tuned for updates as we continue to enhance our Git integration!
Releases are managed via Git tags following Semantic Versioning.
-
Make sure all changes are committed and tested.
-
Create a new tag for the version, for example:
git tag v1.2.3 git push origin v1.2.3
-
GitHub Actions will automatically:
-
Build the Docker image
-
Push it to the registry with tags:
1.2.3latest
-
-
You can pull the image with:
docker pull ghcr.io/zver-in/commitai:1.2.3 docker pull ghcr.io/zver-in/commitai:latest
We welcome contributions! Please see our Contributing Guide for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with ❤️ by the CommitAI team
- Special thanks to all our contributors
For support, please open an issue in the GitHub repository.
The script runs a LangChain agent using tools defined in the selected YAML file (e.g., ./agents/code_reviewer.yaml). The agent configuration is loaded from the YAML file at the path you pass via --agent, so the path must be correct and the file must exist.
Examples:
python -m src.run_agent --agent "$PWD/agents/code_reviewer.yaml" "List files in the prompts/ directory"python -m src.run_agent --agent "$PWD/agents/code_reviewer.yaml" "List files in the src directory"Dependencies for the agent mode (langchain, langchain-openai) are in requirements.txt. If you installed dependencies earlier, re-run installation to ensure everything is up to date:
pip install -r requirements.txt