Revert "feat(ui): redesign menu and add explain, review, changelog, suggest commands"
Build / bun-build (push) Has been cancelled
Build / bun-build (push) Has been cancelled
This reverts commit 1e370be8af.
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
# gai
|
||||
|
||||
**AI-powered Git helper — commit messages, PRs, code review, changelogs, and more**
|
||||
**AI-powered Git commit and pull request helper**
|
||||
|
||||
[](https://git.catpl.top/Mplan/gai/releases)
|
||||
[](./LICENSE)
|
||||
[](https://bun.sh)
|
||||
[](https://www.typescriptlang.org/)
|
||||
|
||||
Generate **Conventional Commits** messages, pull request descriptions, code reviews, changelogs, and more — powered by AI with full project context.
|
||||
Generate **Conventional Commits** messages and pull request descriptions using AI, based on your project context, code diff, branch changes, and commit history.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -16,18 +17,15 @@ Generate **Conventional Commits** messages, pull request descriptions, code revi
|
||||
|
||||
## Features
|
||||
|
||||
- **🤖 AI Commit Messages** — generate Conventional Commits from staged diffs with project context
|
||||
- **🔀 AI Pull Requests** — create GitHub, Gitea, or GitLab PRs with AI-generated title and body
|
||||
- **📖 Explain Changes** — `gai explain` explains diffs in plain language
|
||||
- **🔍 Code Review** — `gai review` provides thorough, constructive code review
|
||||
- **📝 Changelog Generation** — `gai changelog` generates user-facing changelogs from commits
|
||||
- **💡 Smart Suggestions** — `gai suggest` recommends branch names or commit types
|
||||
- **✏️ Amend Commits** — `gai commit --amend` amends with AI-generated message
|
||||
- **⚡ Streaming Output** — AI responses stream token-by-token for instant feedback
|
||||
- **📂 Interactive File Selection** — ↑/↓ navigate, space toggle, "Select all" support
|
||||
- **📋 Pipe Support** — pipe diffs directly: `git diff | gai explain`
|
||||
- **🎨 Mainstream CLI UX** — proper flags, aliases, `--help` per command, `--no-color`
|
||||
- **🔧 OpenAI-compatible API** — works with DeepSeek, OpenAI, Ollama, OpenRouter, and more
|
||||
- **Interactive menu** — `gai` opens a menu, select actions with ↑/↓ + space/enter
|
||||
- **Context-aware commits** — reads project overview, staged diff, and recent commit history
|
||||
- **Conventional Commits** — `feat(scope): description` format by default
|
||||
- **Interactive file selection** — ↑/↓ to navigate, space to select, top-level "Select all"
|
||||
- **Inline editing** — edit AI-generated messages right in the terminal with cursor movement
|
||||
- **AI-generated PRs** — create GitHub, Gitea, or GitLab pull requests with generated title and body
|
||||
- **OpenAI-compatible API** — works with DeepSeek, OpenAI, Ollama, OpenRouter, and more
|
||||
- **Review before commit** — confirm, edit, or abort the generated message
|
||||
- **Bun-native runtime** — built on Bun APIs with no runtime npm dependencies
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -41,196 +39,85 @@ gai config
|
||||
# Open interactive menu
|
||||
gai
|
||||
|
||||
# Generate a commit message
|
||||
# Or directly generate a commit message
|
||||
gai commit
|
||||
|
||||
# Explain your changes
|
||||
gai explain
|
||||
# Or create an AI-generated pull request
|
||||
gai pr
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
gai Open interactive menu
|
||||
gai commit Generate AI commit message (interactive file selection)
|
||||
gai commit -a Auto-stage all changed files
|
||||
gai commit -d Generate message without committing
|
||||
gai commit -m "msg" Use custom message (skip AI)
|
||||
gai commit --amend Amend last commit with AI-generated message
|
||||
gai pr Create a PR with AI-generated title and body
|
||||
gai pr --draft Create a draft PR
|
||||
gai explain Explain staged changes in plain language
|
||||
gai explain --unstaged Explain unstaged changes
|
||||
gai review AI code review of staged changes
|
||||
gai review --strict Thorough review, flag minor issues
|
||||
gai review --lenient Focus only on major issues
|
||||
gai changelog Generate changelog from recent commits
|
||||
gai changelog --from v1.0 --to v1.1 Range-based changelog
|
||||
gai suggest branch Suggest branch names for current changes
|
||||
gai suggest type Suggest Conventional Commit type
|
||||
gai config Configure API settings (interactive)
|
||||
gai config list List all settings
|
||||
gai config get <key> Get a specific setting
|
||||
gai config set <key> <v> Set a setting
|
||||
gai help Show help
|
||||
gai help <command> Show command-specific help
|
||||
gai --version Show version
|
||||
```
|
||||
|
||||
### Global Flags
|
||||
|
||||
| Flag | Description |
|
||||
|---|---|
|
||||
| `-h, --help` | Show help |
|
||||
| `-V, --version` | Show version |
|
||||
| `-v, --verbose` | Verbose output |
|
||||
| `--no-color` | Disable colored output |
|
||||
|
||||
Also respects the `NO_COLOR` and `FORCE_COLOR` environment variables.
|
||||
|
||||
### Subcommand Aliases
|
||||
|
||||
| Command | Aliases |
|
||||
|---|---|
|
||||
| `commit` | `c`, `ci` |
|
||||
| `pr` | `p` |
|
||||
| `config` | `cfg` |
|
||||
| `explain` | `x` |
|
||||
| `review` | `r`, `rv` |
|
||||
| `changelog` | `cl`, `log` |
|
||||
| `suggest` | `sg` |
|
||||
| `help` | `h` |
|
||||
|
||||
### Pipe Support
|
||||
|
||||
All AI commands accept piped input — no git repository required:
|
||||
|
||||
```bash
|
||||
# Explain any diff
|
||||
git diff main..feature | gai explain
|
||||
|
||||
# Review changes from a PR
|
||||
curl https://patch-diff.githubusercontent.com/... | gai review
|
||||
|
||||
# Suggest branch name for a diff
|
||||
git diff | gai suggest branch
|
||||
gai Open interactive menu
|
||||
gai commit Generate commit message (interactive file selection)
|
||||
gai commit --auto Auto-stage all changed files
|
||||
gai commit -d Generate message without committing
|
||||
gai pr Create a PR with AI-generated title and body
|
||||
gai pr --draft Create a draft PR
|
||||
gai config Configure API settings
|
||||
gai --help Show help
|
||||
gai --version Show version
|
||||
```
|
||||
|
||||
### Interactive Menu
|
||||
|
||||
Run `gai` without arguments to open the mole-style interactive menu:
|
||||
|
||||
```
|
||||
gai v0.1.3
|
||||
AI-powered git helper for commits, PRs, reviews, and changelogs
|
||||
────────────────────────────────────────────────────────────────────────
|
||||
$ gai
|
||||
|
||||
CREATE
|
||||
│ › 1 Commit Generate AI commit message
|
||||
2 PR Create a PR with AI-generated title
|
||||
3 Amend Amend last commit with AI message
|
||||
gai
|
||||
Choose a workflow
|
||||
↑/↓ navigate · enter/space select · ctrl+c cancel
|
||||
|
||||
INSPECT
|
||||
4 Explain Explain staged changes in plain language
|
||||
5 Review AI code review of staged changes
|
||||
6 Changelog Generate changelog from commits
|
||||
7 Suggest Suggest branch name or commit type
|
||||
|
||||
PROJECT
|
||||
8 Config Configure API settings
|
||||
|
||||
────────────────────────────────────────────────────────────────────────
|
||||
↑/↓ navigate enter run 1-8 jump h help v version q quit
|
||||
❯ ● commit Generate AI commit message
|
||||
○ pr Create a PR with AI-generated title
|
||||
○ config Configure API settings
|
||||
```
|
||||
|
||||
Number keys `1`–`8` jump directly to the corresponding action. After a command finishes, press Enter to return to the menu.
|
||||
### Commit Flow
|
||||
|
||||
### Command Examples
|
||||
```
|
||||
$ gai commit
|
||||
|
||||
#### Commit
|
||||
Staged files (will be included):
|
||||
✓ src/git.ts (modified)
|
||||
|
||||
Select files to stage:
|
||||
2 unstaged files available
|
||||
↑/↓ navigate · space toggle · enter confirm · ←/backspace back · ctrl+c cancel
|
||||
|
||||
❯ □ Select all
|
||||
□ src/ai.ts modified
|
||||
■ src/newfile.ts new
|
||||
|
||||
Generating commit message...
|
||||
|
||||
Generated commit message:
|
||||
feat(git): add interactive file staging and commit wrapper
|
||||
|
||||
Use this message? [Y/n/e] Y
|
||||
|
||||
✔ Committed successfully!
|
||||
[main a3f7c2b] feat(git): add interactive file staging and commit wrapper
|
||||
1 file changed, 45 insertions(+), 12 deletions(-)
|
||||
```
|
||||
|
||||
### Pull Request Flow
|
||||
|
||||
`gai pr` detects the remote platform from `origin`:
|
||||
|
||||
- GitHub remotes use the `gh` CLI
|
||||
- Gitea remotes use the `tea` CLI
|
||||
- GitLab remotes use the `glab` CLI
|
||||
- Unknown remotes prompt you to choose a platform
|
||||
|
||||
The command compares your current branch against the default branch, pushes the branch if needed, generates a PR title/body from the branch commits and diff, then asks for confirmation before creating the PR.
|
||||
|
||||
```bash
|
||||
# Interactive file selection
|
||||
gai commit
|
||||
|
||||
# Auto-stage everything
|
||||
gai commit -a
|
||||
|
||||
# Dry-run (no commit)
|
||||
gai commit -d
|
||||
|
||||
# Custom message (skip AI)
|
||||
gai commit -m "fix: correct typo in README"
|
||||
|
||||
# Amend last commit with AI message
|
||||
gai commit --amend
|
||||
|
||||
# Pipe diff for commit message
|
||||
git diff --staged | gai commit
|
||||
```
|
||||
|
||||
#### PR
|
||||
|
||||
```bash
|
||||
# Create PR
|
||||
gai pr
|
||||
|
||||
# Draft PR
|
||||
gai pr --draft
|
||||
```
|
||||
|
||||
#### Explain
|
||||
|
||||
```bash
|
||||
# Explain staged changes
|
||||
gai explain
|
||||
|
||||
# Explain unstaged changes
|
||||
gai explain --unstaged
|
||||
|
||||
# Pipe any diff
|
||||
git diff HEAD~3 | gai explain
|
||||
```
|
||||
|
||||
#### Review
|
||||
|
||||
```bash
|
||||
# Review staged changes (normal strictness)
|
||||
gai review
|
||||
|
||||
# Thorough review
|
||||
gai review --strict
|
||||
|
||||
# Lenient review
|
||||
gai review --lenient
|
||||
|
||||
# Review unstaged changes
|
||||
gai review --unstaged
|
||||
```
|
||||
|
||||
#### Changelog
|
||||
|
||||
```bash
|
||||
# From last 20 commits
|
||||
gai changelog
|
||||
|
||||
# Custom count
|
||||
gai changelog -n 50
|
||||
|
||||
# Between tags
|
||||
gai changelog --from v1.0.0 --to v1.1.0
|
||||
```
|
||||
|
||||
#### Suggest
|
||||
|
||||
```bash
|
||||
# Suggest branch name
|
||||
gai suggest branch
|
||||
|
||||
# Suggest commit type
|
||||
gai suggest type
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Via `gai config` (interactive)
|
||||
@@ -239,15 +126,6 @@ gai suggest type
|
||||
gai config
|
||||
```
|
||||
|
||||
### CLI-based config
|
||||
|
||||
```bash
|
||||
gai config list
|
||||
gai config get model
|
||||
gai config set model gpt-4o
|
||||
gai config set temperature 0.3
|
||||
```
|
||||
|
||||
### Via environment variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
@@ -315,14 +193,13 @@ GAI_MODEL=anthropic/claude-sonnet-4
|
||||
│ │
|
||||
│ 2. Collect code changes │
|
||||
│ ├─ git diff --staged for commits │
|
||||
│ ├─ Branch diff for pull requests │
|
||||
│ └─ Pipe support for external diffs │
|
||||
│ └─ branch diff for pull requests │
|
||||
│ │
|
||||
│ 3. Collect commit history │
|
||||
│ ├─ git log --oneline -10 for commits │
|
||||
│ └─ Branch commits for pull requests │
|
||||
│ └─ branch commits for pull requests │
|
||||
│ │
|
||||
│ 4. Build prompt → Call AI API (streaming) │
|
||||
│ 4. Build prompt → Call AI API │
|
||||
│ │
|
||||
│ 5. Review → Confirm → Commit or Create PR │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
Reference in New Issue
Block a user