zdc-smartgit-cli
v1.1.2
Published
AI-powered Git assistant CLI tool
Maintainers
Readme
zdc-smartgit-cli
AI-powered Git assistant CLI tool.
smartgitandaigitcommands are equivalent — use either one interchangeably.
Features
- AI-generated commit messages
- Automated sync workflow with gate confirmations
- Multi-provider support (OpenAI, Anthropic, Ollama)
Installation
npm i -g zdc-smartgit-cliQuick Start
# Interactive menu (no arguments)
smartgit
# Configure your API key
smartgit config
# Commit changes with AI-generated message
aigit commit
# Full workflow: sync, commit, and push
aigit pushCommands
| Command | Description |
|---------|-------------|
| smartgit | Interactive menu - Select action from list |
| smartgit commit | Analyze changes and create commit with AI-generated message |
| smartgit push | Full workflow: sync, commit, and push changes |
Global Options
| Option | Description |
|--------|-------------|
| -y, --yes | Skip non-dangerous confirmations |
| -v, --verbose | Show verbose output |
| --dry-run | Preview execution without making changes |
Configuration
Configuration file location: ~/.aigit/config.json
{
"ai": {
"provider": "openai",
"baseURL": "https://api.openai.com/v1",
"apiKey": "sk-xxx",
"model": "gpt-4o-mini"
},
"git": {
"defaultBranch": "main"
},
"commit": {
"language": "zh" // "zh" for Chinese, "en" for English
},
"filter": {
"ignoreWhitespace": true,
"ignoreComments": true,
"ignoreBuildArtifacts": true,
"mergeCancelingOps": true,
"maxListItems": 7
},
"confirm": {
"level": "interactive"
},
"mr": {
"enabled": true, // Enable MR link generation after push
"platform": "auto" // "auto" | "github" | "gitlab"
}
}Config Options
| Field | Description |
|-------|-------------|
| ai.provider | AI provider: openai, anthropic, or ollama |
| ai.apiKey | Your API key (sk-xxx for OpenAI, sk-ant-xxx for Anthropic) |
| ai.baseURL | API base URL (default depends on provider) |
| ai.model | Model name (default: claude-sonnet-4-20250514 for Anthropic, gpt-4o-mini for OpenAI) |
| git.defaultBranch | Your default branch name (default: main) |
| commit.language | Commit message language: zh (Chinese) or en (English) |
| mr.enabled | Enable MR/PR link generation after push (default: true) |
| mr.platform | Git platform: auto, github, or gitlab |
Commit Message Format
<type>: <description>
- 1. <change item 1>
- 2. <change item 2>
- 3. <change item 3>Types
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting)refactor- Code refactoringperf- Performance improvementstest- Test changeschore- Build/config changes
Example (Chinese)
feat: 添加用户认证模块
- 1. 新增登录页面和表单验证
- 2. 添加 JWT token 生成逻辑
- 3. 集成 OAuth2 第三方登录Example (English)
feat: add user authentication module
- 1. Add login page with form validation
- 2. Add JWT token generation logic
- 3. Integrate OAuth2 third-party loginMerge Request Link
After a successful aigit push, the tool will automatically generate and display a Merge Request (or Pull Request) link.
Supported Platforms
- GitHub - Creates PR link with
?expand=1to auto-expand description - GitLab - Creates MR link with pre-filled source and target branches
Example Output
$ smartgit push
✓ Commit created
✓ Changes pushed to remote
┌──────────────────────────────────────────────┐
│ Create Merge Request │
│ │
│ https://github.com/jangze/smart-git/ │
│ compare/main...feature-auth?expand=1 │
└──────────────────────────────────────────────┘Configuration
To disable MR link generation:
{
"mr": {
"enabled": false
}
}To specify a platform manually:
{
"mr": {
"enabled": true,
"platform": "github"
}
}Workflow
smartgit commit
- Stage all changes (
git add .) - Generate commit message using AI
- Allow user to edit message
- Create commit
smartgit push
- Stage all changes (
git add .) - Check remote branch status → gate confirmation
- Check local master sync status → gate confirmation
- Check if current branch includes latest master → gate confirmation
- Generate commit message using AI
- Allow user to edit message
- Create commit
- Push to remote
License
MIT
