2 Commits

5 changed files with 43 additions and 58 deletions
-3
View File
@@ -10,9 +10,6 @@ dist
coverage coverage
*.lcov *.lcov
# lock
bun.lock
# logs # logs
logs logs
_.log _.log
+14 -38
View File
@@ -17,11 +17,9 @@ 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
@@ -33,56 +31,36 @@ Generate **Conventional Commits** messages using AI — based on your project co
bun install bun install
# Configure your API key # Configure your API key
gai config bun run gai config
# Open interactive menu # Generate a commit message
gai bun run gai
# Or directly generate a commit message
gai commit
``` ```
## Usage ## Usage
``` ```
gai Open interactive menu gai Generate commit message (interactive file selection)
gai commit Generate commit message (interactive file selection) gai --auto Auto-stage all changed files
gai commit --auto Auto-stage all changed files gai --dry-run Generate message without committing
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 Menu ### Interactive Flow
``` ```
$ 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:
@@ -90,9 +68,7 @@ $ gai commit
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
@@ -100,7 +76,7 @@ $ gai commit
### Via `gai config` (interactive) ### Via `gai config` (interactive)
```bash ```bash
gai config bun run gai config
``` ```
### Via environment variables ### Via environment variables
@@ -109,7 +85,7 @@ 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-chat` | Model name | | `GAI_MODEL` | `deepseek-v4-flash` | 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 |
@@ -120,7 +96,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-chat GAI_MODEL=deepseek-v4-flash
``` ```
### Using other providers ### Using other providers
+26
View File
@@ -0,0 +1,26 @@
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "git-ai",
"devDependencies": {
"@types/bun": "latest",
},
"peerDependencies": {
"typescript": "^5",
},
},
},
"packages": {
"@types/bun": ["@types/bun@1.3.14", "https://registry.npmmirror.com/@types/bun/-/bun-1.3.14.tgz", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
"@types/node": ["@types/node@25.9.2", "https://registry.npmmirror.com/@types/node/-/node-25.9.2.tgz", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-G05zqtJhcDLb8uslf5EjCxXg9G1KQxiV8OS0R26IC//Eoyitzqe8z37I7cqvnZlrlSfgocQRfSn/AHBZJJFyGw=="],
"bun-types": ["bun-types@1.3.14", "https://registry.npmmirror.com/bun-types/-/bun-types-1.3.14.tgz", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
"typescript": ["typescript@5.9.3", "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"undici-types": ["undici-types@7.24.6", "https://registry.npmmirror.com/undici-types/-/undici-types-7.24.6.tgz", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
}
}
+2 -16
View File
@@ -277,7 +277,6 @@ 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> {
@@ -305,9 +304,9 @@ async function showMenu(): Promise<void> {
} }
function clearMenu() { function clearMenu() {
process.stdout.write(`\x1b[${headerLines}A`); process.stdout.write(`\x1b[${totalLines}A`);
for (let i = 0; i < totalLines; i++) { for (let i = 0; i < totalLines; i++) {
process.stdout.write("\r\x1b[2K\n"); process.stdout.write("\x1b[2K\x1b[1B");
} }
process.stdout.write(`\x1b[${totalLines}A`); process.stdout.write(`\x1b[${totalLines}A`);
} }
@@ -385,8 +384,6 @@ 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();
} }
@@ -535,11 +532,6 @@ async function main() {
return; return;
} }
if (subcommand === "help") {
showHelp();
return;
}
if (subcommand === "commit") { if (subcommand === "commit") {
const autoMode = args.includes("--auto") || args.includes("-a"); const autoMode = args.includes("--auto") || args.includes("-a");
const dryRun = args.includes("--dry-run") || args.includes("-d"); const dryRun = args.includes("--dry-run") || args.includes("-d");
@@ -557,12 +549,6 @@ 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);
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "gai", "name": "git-ai",
"version": "0.1.0", "version": "0.1.0",
"description": "AI-powered git commit message generator", "description": "AI-powered git commit message generator",
"module": "index.ts", "module": "index.ts",