Compare commits
3 Commits
309b6e94d4
...
78b9c7a0a0
| Author | SHA1 | Date | |
|---|---|---|---|
| 78b9c7a0a0 | |||
| 798cdbbadf | |||
| 0906e304a1 |
@@ -17,9 +17,11 @@ Generate **Conventional Commits** messages using AI — based on your project co
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- **Interactive menu** — `gai` opens a menu, select actions with ↑/↓ + space/enter
|
||||||
- **3-layer context** — project overview, staged diff, and recent commit history
|
- **3-layer context** — project overview, staged diff, and recent commit history
|
||||||
- **Conventional Commits** — `feat(scope): description` format by default
|
- **Conventional Commits** — `feat(scope): description` format by default
|
||||||
- **Interactive file selection** — ↑/↓ to navigate, space to select, top-level "Select all"
|
- **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
|
- **OpenAI-compatible API** — works with DeepSeek, OpenAI, Ollama, and more
|
||||||
- **Review before commit** — confirm, edit, or abort the generated message
|
- **Review before commit** — confirm, edit, or abort the generated message
|
||||||
- **Zero dependencies** — built entirely on Bun native APIs
|
- **Zero dependencies** — built entirely on Bun native APIs
|
||||||
@@ -31,36 +33,56 @@ Generate **Conventional Commits** messages using AI — based on your project co
|
|||||||
bun install
|
bun install
|
||||||
|
|
||||||
# Configure your API key
|
# Configure your API key
|
||||||
bun run gai config
|
gai config
|
||||||
|
|
||||||
# Generate a commit message
|
# Open interactive menu
|
||||||
bun run gai
|
gai
|
||||||
|
|
||||||
|
# Or directly generate a commit message
|
||||||
|
gai commit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
gai Generate commit message (interactive file selection)
|
gai Open interactive menu
|
||||||
gai --auto Auto-stage all changed files
|
gai commit Generate commit message (interactive file selection)
|
||||||
gai --dry-run Generate message without committing
|
gai commit --auto Auto-stage all changed files
|
||||||
|
gai commit -d Generate message without committing
|
||||||
gai config Configure API settings
|
gai config Configure API settings
|
||||||
gai --help Show help
|
gai --help Show help
|
||||||
gai --version Show version
|
gai --version Show version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Interactive Flow
|
### Interactive Menu
|
||||||
|
|
||||||
```
|
```
|
||||||
$ gai
|
$ 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 files to stage:
|
||||||
❯ ◉ Select all
|
❯ ◉ Select all
|
||||||
◉ src/git.ts (modified)
|
|
||||||
○ src/ai.ts (modified)
|
○ src/ai.ts (modified)
|
||||||
◉ src/newfile.ts (new)
|
◉ src/newfile.ts (new)
|
||||||
|
|
||||||
↑/↓ navigate, space select, enter confirm
|
|
||||||
|
|
||||||
Generating commit message...
|
Generating commit message...
|
||||||
|
|
||||||
Generated commit message:
|
Generated commit message:
|
||||||
@@ -68,7 +90,9 @@ $ gai
|
|||||||
|
|
||||||
Use this message? [Y/n/e] Y
|
Use this message? [Y/n/e] Y
|
||||||
|
|
||||||
Committed successfully!
|
✔ Committed successfully!
|
||||||
|
[main a3f7c2b] feat(git): add interactive file staging and commit wrapper
|
||||||
|
1 file changed, 45 insertions(+), 12 deletions(-)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -76,7 +100,7 @@ $ gai
|
|||||||
### Via `gai config` (interactive)
|
### Via `gai config` (interactive)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun run gai config
|
gai config
|
||||||
```
|
```
|
||||||
|
|
||||||
### Via environment variables
|
### Via environment variables
|
||||||
@@ -85,7 +109,7 @@ bun run gai config
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `GAI_API_KEY` | — | **Required.** Your API key |
|
| `GAI_API_KEY` | — | **Required.** Your API key |
|
||||||
| `GAI_API_BASE` | `https://api.deepseek.com/v1` | API base URL |
|
| `GAI_API_BASE` | `https://api.deepseek.com/v1` | API base URL |
|
||||||
| `GAI_MODEL` | `deepseek-v4-flash` | Model name |
|
| `GAI_MODEL` | `deepseek-chat` | Model name |
|
||||||
| `GAI_MAX_TOKENS` | `500` | Max response tokens |
|
| `GAI_MAX_TOKENS` | `500` | Max response tokens |
|
||||||
| `GAI_TEMPERATURE` | `0.7` | Sampling temperature |
|
| `GAI_TEMPERATURE` | `0.7` | Sampling temperature |
|
||||||
|
|
||||||
@@ -96,7 +120,7 @@ Bun auto-loads `.env` — no dotenv needed:
|
|||||||
```bash
|
```bash
|
||||||
GAI_API_KEY=sk-your-key
|
GAI_API_KEY=sk-your-key
|
||||||
GAI_API_BASE=https://api.deepseek.com/v1
|
GAI_API_BASE=https://api.deepseek.com/v1
|
||||||
GAI_MODEL=deepseek-v4-flash
|
GAI_MODEL=deepseek-chat
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using other providers
|
### Using other providers
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ interface MenuAction {
|
|||||||
|
|
||||||
const MENU_ACTIONS: MenuAction[] = [
|
const MENU_ACTIONS: MenuAction[] = [
|
||||||
{ key: "commit", label: "commit", description: "Generate AI commit message" },
|
{ key: "commit", label: "commit", description: "Generate AI commit message" },
|
||||||
|
{ key: "config", label: "config", description: "Configure API settings" },
|
||||||
];
|
];
|
||||||
|
|
||||||
async function showMenu(): Promise<void> {
|
async function showMenu(): Promise<void> {
|
||||||
@@ -304,9 +305,9 @@ async function showMenu(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearMenu() {
|
function clearMenu() {
|
||||||
process.stdout.write(`\x1b[${totalLines}A`);
|
process.stdout.write(`\x1b[${headerLines}A`);
|
||||||
for (let i = 0; i < totalLines; i++) {
|
for (let i = 0; i < totalLines; i++) {
|
||||||
process.stdout.write("\x1b[2K\x1b[1B");
|
process.stdout.write("\r\x1b[2K\n");
|
||||||
}
|
}
|
||||||
process.stdout.write(`\x1b[${totalLines}A`);
|
process.stdout.write(`\x1b[${totalLines}A`);
|
||||||
}
|
}
|
||||||
@@ -384,6 +385,8 @@ async function showMenu(): Promise<void> {
|
|||||||
|
|
||||||
if (selected.key === "commit") {
|
if (selected.key === "commit") {
|
||||||
handleCommit(false, false).then(resolve);
|
handleCommit(false, false).then(resolve);
|
||||||
|
} else if (selected.key === "config") {
|
||||||
|
handleConfig().then(resolve);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
@@ -549,6 +552,12 @@ async function main() {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.on("SIGINT", () => {
|
||||||
|
process.stdout.write("\x1b[?25h");
|
||||||
|
process.stdout.write("\n");
|
||||||
|
process.exit(130);
|
||||||
|
});
|
||||||
|
|
||||||
main().catch((err) => {
|
main().catch((err) => {
|
||||||
console.error(` ${RED}Unexpected error: ${err}${RESET}`);
|
console.error(` ${RED}Unexpected error: ${err}${RESET}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user