VOOZH about

URL: https://deepwiki.com/guanguans/ai-commit/1-overview

⇱ guanguans/ai-commit | DeepWiki


Loading...
Menu

Overview

This page covers what ai-commit is, what it does, its supported AI backends, key features, and the top-level architecture of the codebase. For installation steps, see Getting Started. For detailed CLI usage, see the User Guide. For internal implementation details, see Architecture Deep Dive.


What is ai-commit?

ai-commit is a PHP command-line tool that reads the staged git diff in a repository and calls an AI service to produce a Conventional Commits-formatted commit message. The user then confirms or rejects the message before it is committed.

One-line description (from composer.json): "Automagically generate conventional git commit message with AI."

The tool is distributed as:

  • A self-contained PHAR binary (builds/ai-commit), downloadable directly or via self-update.
  • A Composer package (guanguans/ai-commit).

Runtime requirement: PHP >= 8.2 with the ext-curl and ext-mbstring extensions.

License: MIT

Framework: Laravel Zero — a micro-framework for console applications built on Laravel.

Sources: composer.json1-68 README.md1-45


Supported AI Backends

ai-commit calls these backends through interchangeable "generators". Each has a corresponding driver key used in configuration and the --generator flag.

Driver KeyBackendType
openai_chatOpenAI Chat Completions APIAPI (HTTP)
openaiOpenAI Completions API (legacy)API (HTTP)
moonshotMoonshot (Kimi) APIAPI (HTTP)
ernie_botBaidu ERNIE-BotAPI (HTTP)
ernie_bot_turboBaidu ERNIE-Bot TurboAPI (HTTP)
bito_cliBito CLI (bito binary)CLI subprocess
github_copilot_cliGitHub Copilot CLI (gh copilot)CLI subprocess
github_models_cliGitHub Models CLI (gh models)CLI subprocess

The default generator is openai_chat unless overridden in configuration.

Sources: README.md21-31 composer.json7-37


Key Features

FeatureDescription
AI-generated commit messagesSends git diff --staged output to a selected AI generator and returns a structured JSON message
Conventional commit type selectionInteractive prompt lets the user select or auto-generate the commit type (feat, fix, docs, etc.)
Confirmation loopDisplays the generated message in a table and asks for confirmation before committing
--dry-run modeGenerates and displays the message without executing git commit
--diff optionAccepts explicit diff content instead of reading from git
Three-layer configurationDefaults → global (~/.ai-commit/.ai-commit.json) → local (.ai-commit.json)
config sub-commandset, get, unset, reset, list, edit operations on both global and local config
self-updateUpdates the PHAR binary from GitHub Releases
Retry logicConfigurable retry count and sleep between retries for API failures

Sources: README.md53-239


Top-Level Architecture

Component Relationships

Diagram: Top-level component map


Sources: README.md53-75 composer.json58-68


Commit Workflow Overview

Diagram: CommitCommand data flow


Sources: README.md76-130


Generator Class Hierarchy

Diagram: Generator system — class and interface relationships


Sources: README.md21-31 composer.json58-68


Configuration System

Diagram: Configuration layer merge order


The ConfigManager class (in app/Support/ConfigManager.php) extends the Illuminate Config Repository and performs a three-way merge. The config command reads and writes to either the global or local file depending on the --global flag.

Sources: README.md166-182


Project Structure Summary

PathPurpose
app/Commands/CommitCommand, ConfigCommand, ThanksCommand
app/Generators/GeneratorManager, AbstractGenerator, all driver classes
app/Clients/HTTP client classes for API-based generators
app/Support/ConfigManager, helper functions
app/Contracts/GeneratorContract and other interfaces
config/ai-commit.phpDefault configuration (generators, prompts, commit types)
config/commands.phpCommand registration list
builds/ai-commitCompiled PHAR binary
tests/Pest test suite (Feature + Unit)
.github/workflows/CI/CD workflows (tests, PHPStan, PHP-CS-Fixer, release)

Sources: composer.json133-148 README.md240-266


Further Reading

TopicPage
Installation and first-runGetting Started
End-to-end commit workflowCommit Command Workflow
All CLI flags and optionsCommand Options and Flags
Configuration managementConfiguration Management
All generators in detailAI Generators Overview
Internal architectureArchitecture Deep Dive
Generator implementationGenerator System
Adding a new generatorAdding New Generators
Configuration file formatConfiguration Reference