Skip to main content

AI-powered commit messages and branch naming.

Project description

cmmt

PyPI version

cmmt 是一个由 AI 驱动的命令行工具,旨在帮助您自动生成符合 Conventional Commits 规范的 Git 提交消息和分支名称。

核心功能

  • AI 驱动: 利用 OpenAI 的强大语言模型,根据您的代码变更 (git diff) 生成高质量的提交消息。
  • 遵循规范: 严格遵循 Conventional Commits 规范,提升您代码库的可读性和可维护性。
  • 分支命名: 自动建议清晰、规范的分支名称。
  • 高度可配置: 您可以通过 ~/.cmmt.yml 文件自定义模型、提示语、忽略文件等。
  • 上下文感知: 能够获取 git status, git diff, git log 以及项目文件结构作为上下文,生成更精准的提交信息。
  • 交互式与非交互式: 支持交互式确认,也支持 -y 参数进行自动化操作。

安装部署

您可以通过 pip 来安装 cmmt:

pip install cmmt

或者,如果您使用 uv:

uv pip install cmmt

安装完成后,您需要初始化配置文件并设置您的 OpenAI API 密钥:

cmmt --init

该命令会引导您在 ~/.cmmt.yml 文件中设置 API 密钥、模型、以及其他可选配置。

使用方法

在您的 Git 仓库中,当您已经将变更添加到暂存区后,运行以下命令:

git add .
cmmt

cmmt 将会分析您的变更,并生成建议的提交消息。

常用选项

  • 生成分支名称:
    cmmt -b
    
  • 自动确认并提交:
    cmmt -y
    
  • 提交后自动推送到远程仓库:
    cmmt -p
    
  • 组合使用:
    cmmt -b -y -p
    
  • 提供额外信息: 您可以通过 -e 参数为 AI 提供额外的上下文信息。
    cmmt -e "This change is part of the new authentication feature."
    

配置文件

cmmt 的所有配置都存储在 ~/.cmmt.yml 文件中。您可以通过 cmmt --init 命令来初始化该文件,也可以手动编辑它。

以下是一个配置文件的示例:

openai_api_key: "sk-..."
model: "gpt-4o"
base_url: null
max_tokens: 2048
ignore_files:
  - "package-lock.json"
  - "*.log"
extra_info: "Always respond in Chinese."
git_log_level: "brief" # Can be 'none', 'brief', 'detailed'
git_log_count: 10 # -1 for all
project_structure_enabled: true
project_structure_max_depth: 3
project_structure_ignore:
  - "node_modules/"
force_think: false

许可协议

该项目基于 MIT License 开源。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmmt-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmmt-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file cmmt-0.1.1.tar.gz.

File metadata

  • Download URL: cmmt-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cmmt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 692467517788e59b73312157bc14877923eb2bb77738fef35d85d1dbe128a974
MD5 14aa7fdf7ca8bc5ad557583e27acb585
BLAKE2b-256 278daec3a6c9db6ee75744ab78382dc54cb0ec6e0f1f8a76cd1d868944e2d511

See more details on using hashes here.

File details

Details for the file cmmt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cmmt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cmmt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7ec38196c959f3a6af198f7a765460b3b23e6cd688f62ba65cf6ddd012c4e0e
MD5 711afc338ebb301b9ca93663749288de
BLAKE2b-256 51873c84a406ace0935054d678ba9981ca9165fd30dc8d92b0d357ad9874036e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page