Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocommit commit messages #4049

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nathabonfim59
Copy link

  • PR Description

  • Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

This PR adds the ability to generate commit messages using AI, primarily through GitHub Copilot integration, with potential support for OpenAI-compatible APIs.

Background

This aims to implement #3763, adding AI-assisted commit message generation similar to VS Code's Copilot feature.

While the GitHub Copilot API is not officially public, the implementation doesn't appear to violate the terms of service. However, I understand introducing AI features like this may be a significant direction change for the project, so I'm open to discussion about whether this aligns with lazygit's goals.

This initial scope focuses solely on commit message generation to keep the implementation focused and manageable. Future possibilities like generating release notes, improving squash commit messages, or crafting PR descriptions could be considered later once this core functionality is proven.

The implementation is based on the flow from Zed and Copilot.lua .

I would appreciate some feedback on both the implementation approach and whether this feature could be added to the project.

Current Implementation Status

This is very much a work in progress. Just a proof of concept at the moment

  • GitHub Copilot authentication via device codes
  • Chat completion
  • Support for generic OpenAI-compatible APIs
  • Support for other providers (Antropic, Geminni, Ollama)
  • Diff extraction and processing
  • Commit message style consistency
  • Large diff handling (according to the model size)
  • Model selection configuration (UserConfig?)

Proposed configuration

git:
  commitSuggestions:
    enabled: true
    provider: "github-copilot" # or "openai-compatible"
    modelName: "gpt-4o" # for openai-compatible
    maxDiffSize: 4096 # tokens
    endpoint: "http://localhost:8080" # for self or openai compatible

Note: Tests and documentation will be added as the implementation progresses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant