Skip to content

Latest commit

 

History

History
169 lines (112 loc) · 5.52 KB

README.md

File metadata and controls

169 lines (112 loc) · 5.52 KB

CommitWise

Commit your code Wisely ...

PyPI version Python License: MIT

CommitWise is an AI-powered command-line assistant that turns your Git staged changes into three clear, English Conventional Commit message suggestions.

Choose the AI provider that fits your workflow:

  • Local: run a model on your machine with Ollama.
  • Online: generate suggestions with a model available through OpenRouter.

You stay in control. CommitWise suggests commit messages; it never creates commits or changes your Git repository.

Why CommitWise?

Writing a good commit message takes attention away from the code you're working on. CommitWise reads the changes you've already staged, asks your selected AI provider for three alternatives, validates their format, and lets you choose the one you want.

  • Three suggestions, one staged diff: every suggestion describes the complete staged change set, not an individual file.
  • Your choice of AI: use Ollama locally or OpenRouter online.
  • Conventional Commits: suggestions follow the Conventional Commits header format.
  • Safe by design: Git access is read-only; you decide what gets committed.
  • Global settings: configure providers once and reuse the settings across repositories.
  • Focused changes: a configurable diff-size limit helps keep commits manageable.

Quick start

1. Requirements

  • Python 3.15 or newer
  • Git installed and available on your PATH
  • One configured AI provider:
    • Ollama running locally with a model downloaded, or
    • an OpenRouter API key and model name

2. Install

pip install commitwise

3. Stage your changes and generate suggestions

Stage the files you want to describe:

git add <files>

Then choose one provider:

commitwise --ai-local

or:

commitwise --ai-online

CommitWise displays three suggestions and asks you to select one. The selected message is copied to your clipboard when a clipboard backend is available. Review it, then run the Git commit command yourself.

Choose a provider

Local AI with Ollama

Start Ollama and download a model. For example:

ollama pull llama3.1

The default local endpoint is http://localhost:11434, and the default model is llama3.1.

Run CommitWise:

commitwise --ai-local

Ollama responses are streamed while they are generated. If a stream is interrupted, CommitWise discards the incomplete response and retries the generation from the beginning. It makes up to three total attempts; it does not attempt token-level resume.

Online AI with OpenRouter

Configure your OpenRouter model and API key:

commitwise config set online.model "your-provider/your-model"
commitwise config set online.api_key "YOUR_OPENROUTER_API_KEY"

Then run:

commitwise --ai-online

The API key is stored in your per-user configuration file and masked when configuration is displayed. Treat that file as sensitive and do not share it.

Configuration

Settings are stored globally for your user account, so you do not need to configure every repository separately.

Platform Configuration path
Windows %APPDATA%\\CommitWise\\config.toml
Linux ~/.config/commitwise/config.toml

Show the current configuration (with secrets masked):

commitwise config show

Show the configuration file location:

commitwise config path

Change a setting:

commitwise config set local.model "qwen2.5-coder"
commitwise config set general.max_diff_size 50000

The default staged-diff limit is 50,000 bytes. If the staged diff exceeds the configured limit, CommitWise stops before contacting the AI provider and asks you to split the work into smaller commits.

Safety and behavior

CommitWise is intentionally limited to suggesting messages:

  • It reads staged changes only; unstaged working-tree changes are not included.
  • It does not run git add, git commit, git reset, git checkout, git switch, or git restore.
  • It does not stage, commit, reset, or otherwise modify your working tree, index, refs, or Git history.
  • If nothing is staged or the staged diff is empty, it stops without making an AI request.
  • The local and online flags are mutually exclusive. There is no automatic provider fallback.
  • It requests exactly three single-line Conventional Commit suggestions and rejects structurally invalid output.
  • It does not truncate or automatically split large diffs.

Always review the generated message before using it. AI suggestions can be imperfect, especially when the change itself is ambiguous.

Development

Clone the repository, install the development dependencies, and run the test suite:

git clone https://github.com/hasssan-hasssan/commitwise.git
cd commitwise
python -m pip install -e ".[dev]"
python -m pytest -q

The CI workflow runs the unit tests on Windows and Linux with Python 3.15 and builds the package to smoke-test the installed CLI.

Project links


Commit your code Wisely ...