Sage:AI驅動的Git提交訊息和分支名稱生成器

Sage:AI驅動的Git提交訊息和分支名稱生成器

Hacker News·

Sage是一款新推出的命令行工具,它利用AI(支援OpenAI和Claude等提供商)分析程式碼變更,自動生成有意義的Git提交訊息和分支名稱。該工具提供互動式工作流程供使用者審查和自訂,旨在簡化Git開發流程。

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

To see all available qualifiers, see our documentation.

Uh oh!

There was an error while loading. Please reload this page.

thanipro/sage

Folders and files

Latest commit

History

Repository files navigation

sage

AI-powered Git commit message and branch name generator. Analyze your code changes and generate meaningful commit messages following conventional commits format automatically.

Overview

sage is a command-line tool that integrates with your Git workflow to automatically generate commit messages and branch names by analyzing your code changes using AI. It supports multiple AI providers (OpenAI and Claude) and provides an interactive workflow for reviewing and editing generated messages.

Features

Requirements

Installation

One-Line Install

This will:

Alternative: Clone and Install

Upgrading from Previous Version

The install script handles both fresh installs and upgrades. Simply run it again:

Or if you cloned the repository:

To manually upgrade:

Manual Installation with Cargo

Quick Start

1. Configure API Provider

If you used the automated install script, you've already configured your API key. Otherwise:

2. Make Changes and Commit

3. Review and Confirm

The tool will show you the generated commit message and prompt:

Usage

Basic Commands

Subcommands

The tool will analyze your changes and generate a branch name following the format:

After generating completions, restart your shell or source the completion file.

Commit Message Styles

Use the -t or --style flag to control message format, or set a default in preferences:

Output: feat(auth): add user authentication

Single line following Conventional Commits format.

Output:

Follows proper Git convention: short summary line (max 50 chars), blank line, then detailed body. GitHub shows just the first line in commit lists, but displays the full message when you click on the commit.

Output: add user auth

Ultra-concise for small changes (max 50 chars).

Set Default Style

Set your preferred style to use automatically:

Configuration

Configuration is stored in ~/.sage-config.json:

Interactive Configuration Wizard

Use the wizard for easy configuration:

The wizard provides an interactive menu:

Preferences

Preferences are saved settings that apply automatically to every commit:

Set preferences using the wizard:

Set preferences directly:

View current configuration:

How preferences work:

Supported Models

OpenAI:

Claude:

Command-Line Options

Global Flags

Subcommand-Specific Options

config:

branch:

diff:

Examples

Common Workflows

Integration with Git Workflows

Shell Aliases

Add these to your .bashrc or .zshrc for faster workflows:

How It Works

File Staging: Files specified as arguments are staged using git add. If no files specified, uses already staged changes.

Diff Extraction: Runs git diff --cached to get staged changes and git status --porcelain to get file list.

Smart Truncation: Large diffs are intelligently truncated to stay within AI token limits while preserving important context.

AI Analysis: Sends diff and file changes to configured AI provider (OpenAI or Claude) with a carefully crafted prompt that enforces:

Sanitization: AI response is sanitized to remove any markdown formatting that might slip through.

Interactive Review: User can:

Commit: Executes git commit with the final message.

Optional Push: If -p flag is used, pushes changes to remote.

Security

sage includes several security features:

Troubleshooting

API Key Not Set

Solution: Configure your API key as shown.

No Staged Changes

Solution: Stage files using sage file.rs or sage -a.

Network Errors

Solution: Check your internet connection and API endpoint availability.

Authentication Failed

Solution: Verify your API key is correct using sage config -s.

Editor Not Found

Solution: Set your EDITOR environment variable:

Development

Building from Source

Running Tests

Project Structure

License

MIT

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Acknowledgments

Built with Rust and powered by OpenAI GPT-4 and Anthropic Claude.

About

Resources

Uh oh!

There was an error while loading. Please reload this page.

Stars

Watchers

Forks

Releases

Packages

  0

Uh oh!

There was an error while loading. Please reload this page.

Languages

Footer

Footer navigation

Hacker News

相關文章

  1. Smart Commit:一個保留在 CLI 中的 AI 輔助 Git Commit 工作流程

    4 個月前

  2. Show HN:使用 gitz (Rust 與 AI) 自動化 Git 提交訊息

    4 個月前

  3. 利用 Git 標註 AI 生成的程式碼

    3 個月前

  4. Show HN:Cmt 是一款 AI 驅動的 Git Commit 訊息生成器

    4 個月前

  5. Git Quick:透過 AI 生成的提交訊息加速 Git 工作流程

    5 個月前