# README
ai-commit
๐ ๋ชฉ์ฐจ
โจ Features
ai-commit์ Gemini AI๋ฅผ ํ์ฉํ์ฌ git ์ปค๋ฐ ๋ฉ์์ง๋ฅผ ์๋์ผ๋ก ์์ฑํ๋ CLI ๋๊ตฌ์ ๋๋ค.
ํต์ฌ ๊ธฐ๋ฅ
-
๐ฏ ์ค๋งํธ ๋ถ์
- ์คํ ์ด์ง๋ ๋ณ๊ฒฝ์ฌํญ ์๋ ๋ถ์
- ํ๋ก์ ํธ ์ปจํ ์คํธ ์ดํด
- ์ด์ ์ปค๋ฐ ์คํ์ผ ํ์ต
-
๐ค AI ๊ธฐ๋ฐ ์์ฑ
- Conventional Commits ํ์ ์ค์
- ๋ฉํฐ ๋ผ์ธ ์ค๋ช ์๋ ์์ฑ
- ๋ณ๊ฒฝ ์ฌํญ์ ๋ํ ์์ธํ ์ค๋ช
-
โ๏ธ ๋ฉ์์ง ํธ์ง
- ์์ฑ๋ ๋ฉ์์ง ๊ฒํ ๋ฐ ์์
- ์ ํธํ๋ ํ ์คํธ ์๋ํฐ ์ฌ์ฉ
- ์ปค๋ฐ ์ ์๋ฒฝํ ๋ฉ์์ง ์กฐ์
-
๐ ์ปค์คํฐ๋ง์ด์ง
- ํ ํ๋ฆฟ ๊ธฐ๋ฐ ์ปค๋ฐ ํ์
- ๋ค๊ตญ์ด ์ง์
- ์ค์ ๊ฐ๋ฅํ ์ต์ ๋ค
-
โก๏ธ ๊ฐ๋ฐ์ ๊ฒฝํ
- ๊ฐ๋จํ CLI ์ธํฐํ์ด์ค
- ๋น ๋ฅธ ์ค์น์ ์ค์
- ์ง๊ด์ ์ธ ์ฌ์ฉ๋ฒ
๐ Getting Started
Prerequisites
์์ํ๊ธฐ ์ ์ ๋ค์ ์๊ตฌ์ฌํญ์ ํ์ธํ์ธ์:
์๊ตฌ์ฌํญ | ์ต์ ๋ฒ์ | ์ค์น ๋ฐฉ๋ฒ |
---|---|---|
Go | 1.21+ | ๊ณต์ ์ฌ์ดํธ |
Git | 2.0+ | ๊ณต์ ์ฌ์ดํธ |
Gemini API ํค | - | ๋ฐ๊ธ ๋ฐฉ๋ฒ |
Installation
Windows
- Go ์ค์น
# 1. Go ์ค์น ํ์ผ ๋ค์ด๋ก๋
# https://go.dev/dl/ ์์ Windows MSI ์ค์น ํ์ผ ๋ค์ด๋ก๋
# 2. ์ค์น ํ์ผ ์คํ ํ ๊ธฐ๋ณธ ์ต์
์ผ๋ก ์ค์น
# 3. PowerShell ๋๋ ๋ช
๋ น ํ๋กฌํํธ๋ฅผ ์๋ก ์ด์ด ์ค์น ํ์ธ
go version
- Git ์ค์น
# 1. Git ์ค์น ํ์ผ ๋ค์ด๋ก๋
# https://git-scm.com/download/windows ์์ ๋ค์ด๋ก๋
# 2. ์ค์น ํ์ผ ์คํ ํ ๊ธฐ๋ณธ ์ต์
์ผ๋ก ์ค์น
# 3. PowerShell ๋๋ ๋ช
๋ น ํ๋กฌํํธ๋ฅผ ์๋ก ์ด์ด ์ค์น ํ์ธ
git --version
- PATH ์ค์
# PowerShell ๊ด๋ฆฌ์ ๊ถํ์ผ๋ก ์คํ
$env:Path += ";$env:USERPROFILE\go\bin"
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User) + ";$env:USERPROFILE\go\bin",
[EnvironmentVariableTarget]::User
)
- ai-commit ์ค์น
go install github.com/in-jun/ai-commit@latest
Linux/Ubuntu
# 1. Go ์ค์น
sudo apt install golang-go
# 2. PATH ์ค์
echo 'export PATH=$PATH:~/go/bin' >> ~/.bashrc
source ~/.bashrc
# 3. ai-commit ์ค์น
go install github.com/in-jun/ai-commit@latest
macOS
# 1. Go ์ค์น
brew install go
# 2. PATH ์ค์
echo 'export PATH=$PATH:~/go/bin' >> ~/.zshrc
source ~/.zshrc
# 3. ai-commit ์ค์น
go install github.com/in-jun/ai-commit@latest
API Key Setup
- Google AI Studio ์ ์
- Google ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ
- 'API ํค ๊ด๋ฆฌ' โ '์ API ํค ๋ง๋ค๊ธฐ' ํด๋ฆญ
- ์์ฑ๋ API ํค ๋ณต์ฌ
๐ Usage
Quick Start
graph LR
A[๋ณ๊ฒฝ์ฌํญ ์คํ
์ด์ง] --> B[ai-commit ์คํ]
B --> C{๋ฉ์์ง ๊ฒํ }
C -->|์น์ธ| D[์ปค๋ฐ ์๋ฃ]
C -->|์์ | E[๋ฉ์์ง ํธ์ง]
C -->|๊ฑฐ์ | F[์ทจ์]
E --> D
- API ํค ์ค์
# ๋ฐฉ๋ฒ 1: ํ๊ฒฝ ๋ณ์
# Windows (PowerShell)
$env:API_KEY="your-gemini-api-key"
ai-commit
# Linux/macOS
API_KEY="your-gemini-api-key" ai-commit
# ๋ฐฉ๋ฒ 2: ์ค์ ํ์ผ
ai-commit init # ํ๋กฌํํธ์์ API ํค ์
๋ ฅ
- ์ปค๋ฐ ๋ฉ์์ง ์์ฑ
git add .
ai-commit
Examples
๊ธฐ๋ฅ ์ถ๊ฐ ์์
$ git add feature.go
$ ai-commit
=== Generated Commit Message ===
feat: ์ฌ์ฉ์ ์ธ์ฆ ๋ฏธ๋ค์จ์ด ๊ตฌํ
JWT ๊ธฐ๋ฐ ์ธ์ฆ ์์คํ
์ถ๊ฐ
- ํ ํฐ ๊ฒ์ฆ ๋ก์ง ๊ตฌํ
- ๋ณดํธ๋ ๋ผ์ฐํธ์ ๋ฏธ๋ค์จ์ด ์ ์ฉ
- 401, 403 ์๋ฌ ํธ๋ค๋ง ์ถ๊ฐ
What would you like to do?
[Y]es: Commit with this message
[E]dit: Edit the message
[N]o: Cancel commit
Choice [Y/e/n]:
๋ฒ๊ทธ ์์ ์์
$ git add bug-fix.go
$ ai-commit
=== Generated Commit Message ===
fix: ๋ฉ๋ชจ๋ฆฌ ๋์ ๋ฌธ์ ํด๊ฒฐ
๋ฐฑ๊ทธ๋ผ์ด๋ ์์
์์ ์์ ํ์ผ ์ ๋ฆฌ ๋ก์ง ๊ฐ์
- ์์
์คํจ ์์๋ ์ ๋ฆฌ ๋ณด์ฅ
- ๋ฆฌ์์ค ํด์ ์์ ์ต์ ํ
- ๋ชจ๋ํฐ๋ง ์งํ ์ถ๊ฐ
What would you like to do?
[Y]es: Commit with this message
[E]dit: Edit the message
[N]o: Cancel commit
Choice [Y/e/n]:
๋ฉ์์ง ํธ์ง ์์
$ git add feature.go
$ ai-commit
=== Generated Commit Message ===
feat: ์ฌ์ฉ์ ์ธ์ฆ ๊ตฌํ
JWT ์ธ์ฆ ์์คํ
์ถ๊ฐ
- ํ ํฐ ๊ฒ์ฆ
- ๋ฏธ๋ค์จ์ด ์ ์ฉ
- ์๋ฌ ์ฒ๋ฆฌ
What would you like to do?
[Y]es: Commit with this message
[E]dit: Edit the message
[N]o: Cancel commit
Choice [Y/e/n]: e
# ์ ํํ ์๋ํฐ์์ ๋ฉ์์ง ํธ์ง ํ ์ ์ฅ
Configuration
์ค์ ํ์ผ ์์น:
- Windows:
%USERPROFILE%\.ai-commit\config.yaml
- Linux/macOS:
~/.ai-commit/config.yaml
# API ์ค์
api_key: "your-api-key"
# ์ฑ๋ฅ ์ค์
max_diff_size: 10000 # ์ต๋ diff ํฌ๊ธฐ (๋ฐ์ดํธ)
history_depth: 5 # ๋ถ์ํ ์ด์ ์ปค๋ฐ ์
# UI ์ค์
color_enabled: true # ์ปฌ๋ฌ ์ถ๋ ฅ ํ์ฑํ
# ์ปค๋ฐ ํ
ํ๋ฆฟ
templates:
- prefix: "feat" # ์ ๊ธฐ๋ฅ
description: "์๋ก์ด ๊ธฐ๋ฅ ์ถ๊ฐ"
- prefix: "fix" # ๋ฒ๊ทธ ์์
description: "๋ฒ๊ทธ ์์ "
# ... ์ถ๊ฐ ํ
ํ๋ฆฟ
Commands
๋ช ๋ น์ด | ์ค๋ช | ์ฌ์ฉ ์์ |
---|---|---|
ai-commit | ์ปค๋ฐ ๋ฉ์์ง ์์ฑ | ai-commit |
ai-commit init | ์ค์ ์ด๊ธฐํ/๊ฐฑ์ | ai-commit init |
ai-commit -h | ๋์๋ง ํ์ | ai-commit -h |
ai-commit -v | ๋ฒ์ ์ ๋ณด ํ์ | ai-commit -v |
์ต์ | ์ค๋ช | ์ฌ์ฉ ์์ |
---|---|---|
Y ๋๋ Enter | ์์ฑ๋ ๋ฉ์์ง๋ก ์ปค๋ฐ | ๋ฉ์์ง๊ฐ ์ ์ ํ ๋ |
E | ๋ฉ์์ง ํธ์ง ๋ชจ๋ ์ง์ | ๋ฉ์์ง ์์ ์ด ํ์ํ ๋ |
N | ์ปค๋ฐ ์ทจ์ | ๋ฉ์์ง๊ฐ ๋ถ์ ์ ํ ๋ |
๐ง Advanced
Best Practices
์ค์ฒ ์ฌํญ | ์ค๋ช | ์์ |
---|---|---|
์์ ๋จ์๋ก ์ปค๋ฐ | โข ํ๋์ ๋
ผ๋ฆฌ์ ๋ณ๊ฒฝ์ฌํญ๋ง ํฌํจ โข ๊ด๋ จ ์๋ ๋ณ๊ฒฝ์ฌํญ์ ๋ถ๋ฆฌ | bash# ์ข์ ์git add auth/ai-commit# ๋์ ์git add . # ์ฌ๋ฌ ๊ธฐ๋ฅ ๋ณ๊ฒฝ |
๋ฉ์์ง ๊ฒํ | โข ์๋ ์์ฑ๋ ๋ฉ์์ง ๊ฒ์ฆ โข ํ์์ ๋ฉ์์ง ํธ์ง์ผ๋ก ์ ํ๋ ํฅ์ | bash# ๋ฉ์์ง ๊ฒํ ํ ์์ What would you like to do?Choice [Y/e/n]: e |
Templates
ํ์ฌ ๊ธฐ๋ณธ ์ปค๋ฐ ํ์ :
Type | Description | ์ฌ์ฉ ์์ |
---|---|---|
feat | ์๋ก์ด ๊ธฐ๋ฅ ์ถ๊ฐ | ๊ธฐ๋ฅ ๊ฐ๋ฐ ์๋ฃ์ |
fix | ๋ฒ๊ทธ ์์ | ๋ฒ๊ทธ ํด๊ฒฐ์ |
docs | ๋ฌธ์ ์์ | ๋ฌธ์ ์์ ์ |
style | ์ฝ๋ ์คํ์ผ ๋ณ๊ฒฝ | ํฌ๋งทํ , ์ธ๋ฏธ์ฝ๋ก ๋ฑ |
refactor | ์ฝ๋ ๋ฆฌํฉํ ๋ง | ๊ตฌ์กฐ ๊ฐ์ ์ |
test | ํ ์คํธ ์ถ๊ฐ/์์ | ํ ์คํธ ์์ ์ |
chore | ๊ธฐํ ๋ณ๊ฒฝ์ฌํญ | ๋น๋ ์คํฌ๋ฆฝํธ ๋ฑ |
Customization
์ปค์คํ ํ ํ๋ฆฟ ์์:
templates:
- prefix: "feature"
description: "์๋ก์ด ๊ธฐ๋ฅ ๊ฐ๋ฐ"
- prefix: "bugfix"
description: "๋ฒ๊ทธ ์์ "
- prefix: "hotfix"
description: "๊ธด๊ธ ์์ "
๐ Troubleshooting
๊ณตํต ๋ฌธ์
command not found: ai-commit
- Go ์ค์น ํ์ธ
go version
- PATH ์ค์ ํ์ธ
# Windows (PowerShell)
echo $env:Path
# Linux/macOS
echo $PATH | grep go
- Go bin ๋๋ ํ ๋ฆฌ ํ์ธ
# Windows
dir %USERPROFILE%\go\bin
# Linux/macOS
ls ~/go/bin
Windows ํน์ ๋ฌธ์
go install
์คํจ ์
# Go ํ๊ฒฝ ๋ณ์ ํ์ธ
go env GOPATH
go env GOBIN
# Go ๋ชจ๋ ์บ์ ์ ๋ฆฌ
go clean -modcache
- PATH ์ค์ ๋ฌธ์
# ํ์ฌ PATH ํ์ธ
echo $env:Path
# ์ฌ์ฉ์ ํ๊ฒฝ ๋ณ์์์ ์๋์ผ๋ก ์ถ๊ฐ
# ์ ์ดํ > ์์คํ
> ๊ณ ๊ธ ์์คํ
์ค์ > ํ๊ฒฝ ๋ณ์
# ์ฌ์ฉ์ ๋ณ์์ Path์ %USERPROFILE%\go\bin ์ถ๊ฐ
- Git Bash ์ฌ์ฉ ์
# ~/.bashrc ํ์ผ ์์ฑ ๋๋ ํธ์ง
echo 'export PATH=$PATH:~/go/bin' >> ~/.bashrc
source ~/.bashrc
- ๊ถํ ๋ฌธ์
# PowerShell์ ๊ด๋ฆฌ์ ๊ถํ์ผ๋ก ์คํ
# ์คํ ์ ์ฑ
ํ์ธ
Get-ExecutionPolicy
# ํ์์ ์คํ ์ ์ฑ
๋ณ๊ฒฝ
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Linux/macOS ํน์ ๋ฌธ์
- PATH ์ฌ์ค์
# Linux
echo 'export PATH=$PATH:~/go/bin' >> ~/.bashrc
source ~/.bashrc
# macOS
echo 'export PATH=$PATH:~/go/bin' >> ~/.zshrc
source ~/.zshrc
- ๊ถํ ๋ฌธ์
# ์คํ ๊ถํ ํ์ธ
ls -l ~/go/bin/ai-commit
# ๊ถํ ๋ถ์ฌ
chmod +x ~/go/bin/ai-commit
API ํค ๋ฌธ์
- ํ๊ฒฝ ๋ณ์ ํ์ธ
# Windows (PowerShell)
echo $env:API_KEY
# Linux/macOS
echo $API_KEY
- ์ค์ ํ์ผ ํ์ธ
# Windows
type %USERPROFILE%\.ai-commit\config.yaml
# Linux/macOS
cat ~/.ai-commit/config.yaml
- ์ค์ ์ด๊ธฐํ
ai-commit init
๐ก FAQs
Q: API ํค๋ ์ด๋์ ์ป๋์?
- Google AI Studio์์ ๋ฐ๊ธ
- ๋ฌด๋ฃ๋ก ์ฌ์ฉ ๊ฐ๋ฅ
- ์ผ์ผ ์์ฒญ ์ ํ ์์
Q: ์คํ๋ผ์ธ์์๋ ์ฌ์ฉ ๊ฐ๋ฅํ๊ฐ์?
- ํ์ฌ ๋ฒ์ ์ Gemini API ์ฐ๊ฒฐ ํ์
- ์คํ๋ผ์ธ ๋ชจ๋๋ ํฅํ ์ง์ ์์
Q: ๋ค๋ฅธ ์ธ์ด๋ ์ง์ํ๋์?
- ํ๋ก์ ํธ์ ์ปค๋ฐ ํ์คํ ๋ฆฌ ๊ธฐ๋ฐ์ผ๋ก ์ธ์ด ์๋ ์ ํ
- ์์ด/ํ๊ตญ์ด ๊ธฐ๋ณธ ์ง์
Q: ์ด๋ค ์๋ํฐ๋ก ๋ฉ์์ง๋ฅผ ํธ์งํ ์ ์๋์?
Windows:
- ๊ธฐ๋ณธ ๋ฉ๋ชจ์ฅ
- Visual Studio Code
- Notepad++
- Git ์ค์น ์ ์ค์ ๋ ๊ธฐ๋ณธ ์๋ํฐ
Linux/macOS:
- vim
- nano
- Visual Studio Code
- ์์คํ ์ ๊ธฐ๋ณธ ์๋ํฐ(VISUAL/EDITOR ํ๊ฒฝ๋ณ์)
์ค์ ๋ฐฉ๋ฒ:
# Windows (PowerShell)
$env:EDITOR="code --wait"
# Linux/macOS
export EDITOR="vim"
Q: ์ปค๋ฐ ๋ฉ์์ง ํ์์ ์ปค์คํฐ๋ง์ด์ฆํ ์ ์๋์?
- ์ค์ ํ์ผ์์ ํ ํ๋ฆฟ ์์ ๊ฐ๋ฅ
- ๊ธฐ์ /ํ ์ปค๋ฐ ์ปจ๋ฒค์ ์ ๋ง์ถฐ ์กฐ์ ๊ฐ๋ฅ
- ์ปค์คํ prefix์ description ์ถ๊ฐ ๊ฐ๋ฅ
Q: ๋๊ท๋ชจ ๋ณ๊ฒฝ์ฌํญ๋ ์ฒ๋ฆฌ ๊ฐ๋ฅํ๊ฐ์?
- ๊ธฐ๋ณธ์ ์ผ๋ก 10,000๋ฐ์ดํธ๊น์ง์ diff ์ฒ๋ฆฌ
- ์ค์ ์์
max_diff_size
์กฐ์ ๊ฐ๋ฅ - ๋๊ท๋ชจ ๋ณ๊ฒฝ์ ์์ ๋จ์๋ก ๋๋์ด ์ปค๋ฐ ๊ถ์ฅ
Made with โค๏ธ by in-jun