aicommit2

repository·main·Indexed 19 days ago

https://github.com/tak-bro/aicommit2

A reactive CLI tool that automatically generates commit messages for Git, YADM, and Jujutsu repositories using various AI providers including OpenAI, Anthropic, Ollama, Gemini, and others. It features support for conventional and gitmoji formats, LazyGit integration, Git hook installation, and the ability to rewrite existing commit messages.

Tokens
39.8K
Snippets
128
Records
182
Agent score
66%

What's inside aicommit2

  1. Use the experimental Code Review feature

    main

    The codeReview feature performs an automated code review before generating the commit message.

    CAUTION: This is an experimental feature. It significantly increases processing time, token consumption, and cost.

    To enable it:

    aicommit2 config set codeReview=true

    You can also specify a custom prompt for the review using codeReviewPromptPath.

    aicommit2 config set codeReview=true
    aicommit2 config set codeReviewPromptPath="/path/to/user/prompt.txt"
  2. Understand configuration precedence in aicommit2

    main

    aicommit2 resolves settings using a specific hierarchy. If a setting is defined in multiple places, the one higher in this list takes precedence:

    1. Command-line arguments (e.g., --OPENAI.locale="jp")
    2. Environment variables (e.g., OPENAI_API_KEY=...)
    3. Configuration file (config.ini)
    4. Model-Specific Settings (settings within a provider section like [OPENAI])
    5. General Settings (global settings like temperature)
    6. Default values
  3. Advanced OpenRouter usage: Structured Output and Reasoning

    main

    OpenRouter supports advanced features like structured output and reasoning-specific controls through specific payload objects:

    • Structured Output: To ensure the model returns structured data, set OPENROUTER.responseFormat to a JSON object (e.g., {"type":"json_object"}).
    • Routing Control: For more granular control over how OpenRouter routes your request, set the OPENROUTER.provider object directly in your configuration.
    • Reasoning: To use reasoning-specific controls, set the OPENROUTER.reasoning object.

    If you encounter issues where a model does not support your chosen format, run aicommit2 doctor to check catalog reachability and receive suggestions for compatible responseFormat or reasoning options.

  4. How DeepSeek thinking mode works

    main

    DeepSeek's thinking mode can be controlled via DEEPSEEK.thinking and DEEPSEEK.reasoningEffort settings.

    When thinking is enabled, aicommit2 sends the thinking and reasoning_effort parameters in the JSON body.

    Important Behavior: When thinking is on, the DeepSeek API ignores temperature, top_p, presence_penalty, and frequency_penalty. To ensure compatibility with the API, aicommit2 automatically omits temperature and topP from the request when thinking mode is active.

    Default Thinking Behavior by Model:

    Model / aliasDefault thinking
    deepseek-v4-flashenabled
    deepseek-v4-proenabled
    deepseek-reasonerenabled (legacy alias)
    deepseek-r1, deepseek-r1-*enabled
    deepseek-chatdisabled (legacy alias)
    Other namesdisabled

    You can override these defaults explicitly:

    aicommit2 config set DEEPSEEK.thinking=false
    aicommit2 config set DEEPSEEK.reasoningEffort=max
  5. How aicommit2 works

    main

    The tool operates by running a diff command (e.g., git diff) to capture your latest code changes. This diff is then sent to your configured AI provider, which generates a structured commit message based on the changes.

    Troubleshooting Large Diffs: If your diff is too large, the AI may fail to process it or return invalid messages. If you encounter errors related to message length or validity, try reducing the size of your commit unit (i.e., commit fewer files at once).

  6. Understanding Bedrock Model ID formats

    main

    Bedrock uses different ID formats depending on whether you want single-region or multi-region availability.

    Foundation Model IDs (Region-Specific)

    Format: provider.model-name-version:0 (e.g., anthropic.claude-haiku-4-5-20251001-v1:0) Use this for simple, single-region deployments where you want requests sent to a specific AWS region.

    Cross-Region Inference Profile IDs (Multi-Region)

    Format: [prefix].provider.model-name-version:0 (e.g., us.anthropic.claude-haiku-4-5-20251001-v1:0) These route requests across multiple regions for better availability, throughput, and latency. Some newer models (like Claude 3.7 Sonnet) require this format.

    Available Prefixes:

    • global.: Worldwide routing (best availability, ~10% cost savings).
    • us., eu., apac., ca., jp., au.: Regional routing (e.g., US, EU, Asia-Pacific).
    • us-gov.: US Government regions only.
  7. Understand Amazon Bedrock Model ID Formats

    main

    Amazon Bedrock supports two main types of Model IDs. Choosing the correct one is critical for model availability and performance:

    1. Foundation Model Format: The standard ID for a specific model (e.g., anthropic.claude-haiku-4-5-20251001-v1:0).
    2. Inference Profile Format: Prefixed IDs used for cross-region inference or specific regional routing. These are required for certain newer models like Claude 3.7 Sonnet.

    Common Prefixes:

    • global. (Global inference profile)
    • us. (US regional inference profile)
    • eu. (EU regional inference profile)

    Example Model IDs:

    • Claude 3.7 Sonnet: us.anthropic.claude-3-7-sonnet-20250219-v1:0 (Requires inference profile)
    • Claude Sonnet 4.5: anthropic.claude-sonnet-4-5-20250929-v1:0 or us.anthropic.claude-sonnet-4-5-20250929-v1:0
    • Llama 3.3 70B: meta.llama3-3-70b-instruct-v1:0
    • Amazon Nova Premier: amazon.nova-premier-v1:0
  8. Authenticate with the COPILOT_SDK provider

    main

    There are two ways to authenticate with the COPILOT_SDK provider:

    This is the easiest method and requires no environment variables. Run the following commands in your terminal:

    1. copilot
    2. /login (to authenticate)
    3. /model (to select your preferred model)

    2. Token-based Authentication (Advanced/CI)

    For headless or CI environments, use a Fine-Grained PAT (github_pat_...) with the Copilot Requests permission.

    • Set the COPILOT_GITHUB_TOKEN environment variable.
    • Note: Classic PATs (ghp_...) are not supported.
    • aicommit2 isolates this auth: it uses COPILOT_GITHUB_TOKEN and ignores GH_TOKEN or GITHUB_TOKEN for COPILOT_SDK requests.
    # For CI/Headless environments
    export COPILOT_GITHUB_TOKEN=github_pat_...
  9. Set up GitHub Models provider

    main

    To use GitHub Models with aicommit2, you can either use the recommended automatic login via the GitHub CLI or manually configure a Personal Access Token (PAT).

    This method authenticates using the GitHub CLI, stores the token in GITHUB_MODELS.key, and verifies your access.

    aicommit2 github-login

    Prerequisites: You must have the GitHub CLI installed on your system.

    Option 2: Manual token setup

    If you prefer using a PAT, ensure the token has the models: read permission. You can then configure it using the github-login command with the --token flag or by setting the config key directly.

    aicommit2 github-login --token github_pat_xxxxxxxxxxxxxxxxxxxx
    # or
    aicommit2 config set GITHUB_MODELS.key="github_pat_xxxxxxxxxxxxxxxxxxxx"
    aicommit2 github-login
  10. Load multiple Ollama models simultaneously

    main

    Starting from Ollama v0.1.33 and aicommit2 v1.9.5, you can make simultaneous requests to multiple models using Ollama's experimental parallel loading feature.

    1. Start the Ollama server with the OLLAMA_MAX_LOADED_MODELS environment variable set to the number of models you want to load:
      OLLAMA_MAX_LOADED_MODELS=3 ollama serve
    2. Configure aicommit2 to use a comma-separated list of models:
      aicommit2 config set OLLAMA.model="mistral,dolphin-llama3"
    3. Run aicommit2 as usual.
    OLLAMA_MAX_LOADED_MODELS=3 ollama serve
    aicommit2 config set OLLAMA.model="mistral,dolphin-llama3"
    aicommit2
  11. Configure API keys via environment variables

    main

    For CI/CD or security, you can provide API keys using environment variables. These take precedence over the configuration file. The standard variable names are:

    • OPENAI_API_KEY
    • ANTHROPIC_API_KEY
    • GEMINI_API_KEY
    • MISTRAL_API_KEY
    • CODESTRAL_API_KEY
    • COHERE_API_KEY
    • GROQ_API_KEY
    • PERPLEXITY_API_KEY
    • DEEPSEEK_API_KEY

    You can customize which environment variable a provider looks for by setting the envKey property in your configuration.

    OPENAI_API_KEY="your-openai-key" ANTHROPIC_API_KEY="your-anthropic-key" aicommit2
  12. Set up Claude Code as a commit message provider

    main

    You can use your locally installed Claude Code CLI as a provider for aicommit2. This allows you to use your Claude Pro/Max subscription for generating commit messages without needing an Anthropic API key.

    Requirements

    • Claude Code CLI installed: Install it globally via npm: npm install -g @anthropic-ai/claude-code.
    • Authentication: You must run claude at least once in your terminal and complete the login process.
    • Subscription: You must have an active Claude Pro or Max subscription, as each request consumes your subscription quota.

    Configuration

    This provider is opt-in. It remains inactive until you explicitly configure a model. You can configure it via the CLI or by editing your configuration file.

    To activate it using the CLI, set the model (e.g., sonnet, opus, or haiku):

    aicommit2 config set CLAUDE_CODE.model=sonnet
    npm install -g @anthropic-ai/claude-code
    aicommit2 config set CLAUDE_CODE.model=sonnet