Mplan 6ff541284e feat(cli): add pull request creation with AI-generated messages (#2)
Add a new `gai pr` subcommand that generates pull request titles and descriptions using AI, then creates the PR via GitHub CLI (`gh`) or Gitea CLI (`tea`). This extends the existing commit-generation system by reusing retry logic and prompt infrastructure, and introduces a `callAI` function that returns raw output (instead of pre-cleaned messages) to support structured PR responses.

Reviewed-on: #2
2026-06-11 00:39:20 +08:00
2026-06-11 00:01:40 +08:00
2026-06-09 17:20:53 +08:00

gai

AI-powered git commit message generator

Version License: MIT Bun TypeScript

Generate Conventional Commits messages using AI — based on your project context, code diff, and commit history.


Features

  • Interactive menugai opens a menu, select actions with ↑/↓ + space/enter
  • 3-layer context — project overview, staged diff, and recent commit history
  • Conventional Commitsfeat(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
  • OpenAI-compatible API — works with DeepSeek, OpenAI, Ollama, and more
  • Review before commit — confirm, edit, or abort the generated message
  • Zero dependencies — built entirely on Bun native APIs

Quick Start

# Install dependencies
bun install

# Configure your API key
gai config

# Open interactive menu
gai

# Or directly generate a commit message
gai commit

Usage

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 config         Configure API settings
gai --help         Show help
gai --version      Show version

Interactive Menu

$ gai

  gai

  ↑/↓ navigate, space/enter select

   ◉ commit          Generate AI commit message

Commit Flow

$ gai commit

  Staged files (will be included):
    ✓ src/git.ts (modified)

  Unstaged files:
    1. src/ai.ts (modified)
    2. src/newfile.ts (new)

  Select files to stage:
     ◉ 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(-)

Configuration

Via gai config (interactive)

gai config

Via environment variables

Variable Default Description
GAI_API_KEY Required. Your API key
GAI_API_BASE https://api.deepseek.com/v1 API base URL
GAI_MODEL deepseek-chat Model name
GAI_MAX_TOKENS 500 Max response tokens
GAI_TEMPERATURE 0.7 Sampling temperature

Via .env file

Bun auto-loads .env — no dotenv needed:

GAI_API_KEY=sk-your-key
GAI_API_BASE=https://api.deepseek.com/v1
GAI_MODEL=deepseek-chat

Using other providers

OpenAI
GAI_API_KEY=sk-xxx
GAI_API_BASE=https://api.openai.com/v1
GAI_MODEL=gpt-4o
Ollama (local)
GAI_API_KEY=ollama
GAI_API_BASE=http://localhost:11434/v1
GAI_MODEL=llama3
OpenRouter
GAI_API_KEY=sk-or-xxx
GAI_API_BASE=https://openrouter.ai/api/v1
GAI_MODEL=anthropic/claude-sonnet-4

How It Works

┌─────────────────────────────────────────────┐
│                gai                           │
├─────────────────────────────────────────────┤
│  1. Collect project context                  │
│     ├─ README.md / package.json              │
│     └─ Directory structure                   │
│                                              │
│  2. Collect code changes                     │
│     └─ git diff --staged                     │
│                                              │
│  3. Collect commit history                   │
│     └─ git log --oneline -10                 │
│                                              │
│  4. Build prompt → Call AI API               │
│                                              │
│  5. Review → Confirm → Commit                │
└─────────────────────────────────────────────┘

Build

Compile to a standalone binary:

bun run build
# Output: ./gai

Test

bun test

License

MIT

S
Description
No description provided
Readme MIT 362 KiB
v0.1.2 Latest
2026-06-12 09:00:55 +08:00
Languages
TypeScript 100%