Skip to content

Commit a186481

Browse files
authored
Merge pull request #17 from BeyteFlow/copilot/add-readme-documentation
docs: add production-quality README.md for git-ai CLI
2 parents 74c45f5 + 66c7504 commit a186481

1 file changed

Lines changed: 345 additions & 0 deletions

File tree

README.md

Lines changed: 345 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
# git-ai
2+
3+
> AI-Powered Visual Git CLI for modern developers
4+
5+
[![CI](https://github.com/BeyteFlow/git-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/BeyteFlow/git-ai/actions/workflows/ci.yml)
6+
[![CodeQL](https://github.com/BeyteFlow/git-ai/actions/workflows/codeql.yml/badge.svg)](https://github.com/BeyteFlow/git-ai/actions/workflows/codeql.yml)
7+
[![npm version](https://img.shields.io/npm/v/git-ai.svg)](https://www.npmjs.com/package/git-ai)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9+
[![Node.js](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)](https://nodejs.org/)
10+
11+
`git-ai` is a terminal-native CLI that brings AI into your everyday Git workflow. It generates meaningful commit messages from your staged diff, resolves merge conflicts automatically, and gives you an interactive TUI for browsing GitHub Pull Requests — all without leaving your terminal.
12+
13+
---
14+
15+
## Features
16+
17+
- **AI commit messages** — Analyze staged changes and generate conventional, context-aware commit messages via Google Gemini.
18+
- **Merge conflict resolution** — Detect all conflicted files and apply AI-suggested resolutions in one command.
19+
- **Interactive PR viewer** — Browse, filter, and inspect GitHub Pull Requests in a rich terminal UI built with [Ink](https://github.com/vadimdemedes/ink).
20+
- **Guided setup** — A single `init` command walks you through connecting your API keys and preferences.
21+
- **Secure config** — Credentials are stored in `~/.aigitrc` with `0600` permissions, never in your repo.
22+
- **Type-safe configuration** — Config schema validated at runtime with [Zod](https://zod.dev/).
23+
24+
---
25+
26+
## Installation
27+
28+
### npm (recommended)
29+
30+
```bash
31+
npm install -g git-ai
32+
```
33+
34+
### From source
35+
36+
```bash
37+
git clone https://github.com/BeyteFlow/git-ai.git
38+
cd git-ai/git-ai
39+
npm install
40+
npm run build
41+
npm install -g .
42+
```
43+
44+
**Requirements:** Node.js `>= 20.0.0`
45+
46+
---
47+
48+
## Quick Start
49+
50+
```bash
51+
# 1. Configure your API keys
52+
ai-git init
53+
54+
# 2. Stage your changes as usual
55+
git add .
56+
57+
# 3. Let AI write the commit message
58+
ai-git commit
59+
```
60+
61+
---
62+
63+
## Usage
64+
65+
### `ai-git init`
66+
67+
Run once to set up your Gemini API key and preferences. Saves config to `~/.aigitrc`.
68+
69+
```bash
70+
ai-git init
71+
```
72+
73+
You will be prompted for:
74+
75+
| Prompt | Description |
76+
|--------|-------------|
77+
| Gemini API Key | Your key from [Google AI Studio](https://aistudio.google.com/app/apikey) |
78+
| Model name | Defaults to `gemini-1.5-flash` |
79+
80+
If a config already exists you can choose to **overwrite**, create a **backup**, or **cancel**.
81+
82+
---
83+
84+
### `ai-git commit`
85+
86+
Generates a commit message for your currently staged changes and lets you accept, edit, or reject it before committing.
87+
88+
```bash
89+
git add src/feature.ts
90+
ai-git commit
91+
```
92+
93+
Example session:
94+
95+
```
96+
🤖 Analyzing changes with Gemini...
97+
98+
✨ Suggested message: "feat(auth): add JWT refresh token rotation"
99+
100+
Choose [a]ccept, [e]dit, or [r]eject: a
101+
✅ Committed successfully!
102+
```
103+
104+
- `a` / `accept` — Commit with the suggested message.
105+
- `e` / `edit` — Manually type a replacement message.
106+
- `r` / `reject` — Abort the commit.
107+
108+
Commit messages are validated against the following rules before being applied:
109+
110+
- Cannot be empty or whitespace-only.
111+
- Must be 72 characters or fewer.
112+
- Must not contain control characters.
113+
114+
---
115+
116+
### `ai-git prs`
117+
118+
Opens an interactive terminal UI for browsing GitHub Pull Requests in the current repository.
119+
120+
```bash
121+
ai-git prs
122+
```
123+
124+
Requires a `github.token` entry in your `~/.aigitrc` (see [Configuration](#configuration)).
125+
126+
---
127+
128+
### `ai-git resolve`
129+
130+
Detects all files with active merge conflicts and applies AI-generated resolutions to each one.
131+
132+
```bash
133+
git merge feature-branch
134+
ai-git resolve
135+
```
136+
137+
Example output:
138+
139+
```
140+
🤖 Resolving: src/utils/parser.ts...
141+
✅ Applied AI fix to src/utils/parser.ts
142+
143+
🎉 Successfully resolved 1 file(s).
144+
```
145+
146+
Review the applied changes with `git diff` before staging and committing.
147+
148+
---
149+
150+
## Command Reference
151+
152+
| Command | Description |
153+
|---------|-------------|
154+
| `ai-git init` | Interactive setup wizard for API keys and preferences |
155+
| `ai-git commit` | Generate an AI commit message for staged changes |
156+
| `ai-git prs` | Launch interactive GitHub PR browser |
157+
| `ai-git resolve` | Auto-resolve merge conflicts using AI |
158+
| `ai-git --version` | Print the current version |
159+
| `ai-git --help` | Show help for all commands |
160+
161+
---
162+
163+
## Configuration
164+
165+
Configuration is stored in `~/.aigitrc` as a JSON file with `0600` permissions.
166+
167+
```jsonc
168+
{
169+
"ai": {
170+
"provider": "gemini", // "gemini" | "openai"
171+
"apiKey": "YOUR_API_KEY",
172+
"model": "gemini-1.5-flash" // optional, defaults to gemini-1.5-flash
173+
},
174+
"github": {
175+
"token": "ghp_..." // optional, required for `ai-git prs`
176+
},
177+
"git": {
178+
"autoStage": false, // auto-run `git add -A` before committing
179+
"messagePrefix": "" // optional prefix prepended to every message
180+
},
181+
"ui": {
182+
"theme": "dark", // "dark" | "light" | "system"
183+
"showIcons": true
184+
}
185+
}
186+
```
187+
188+
Re-run `ai-git init` at any time to update your configuration.
189+
190+
---
191+
192+
## Examples
193+
194+
### Generate a commit after a bug fix
195+
196+
```bash
197+
git add src/api/handler.ts
198+
ai-git commit
199+
# 🤖 Analyzing changes with Gemini...
200+
# ✨ Suggested message: "fix(api): handle null response from upstream service"
201+
# Choose [a]ccept, [e]dit, or [r]eject: a
202+
# ✅ Committed successfully!
203+
```
204+
205+
### Recover from a messy merge
206+
207+
```bash
208+
git merge origin/main
209+
# CONFLICT (content): Merge conflict in src/config.ts
210+
ai-git resolve
211+
# 🤖 Resolving: src/config.ts...
212+
# ✅ Applied AI fix to src/config.ts
213+
git add src/config.ts
214+
git commit
215+
```
216+
217+
### Review open PRs before merging
218+
219+
```bash
220+
ai-git prs
221+
# Opens an interactive TUI listing all open pull requests
222+
```
223+
224+
---
225+
226+
## Project Structure
227+
228+
```
229+
git-ai/
230+
├── src/
231+
│ ├── index.ts # CLI entry point (Commander.js)
232+
│ ├── commands/
233+
│ │ ├── CommitCommand.ts # AI commit message generation
234+
│ │ ├── InitCommand.ts # Setup wizard
235+
│ │ ├── ResolveCommand.ts # Merge conflict resolver
236+
│ │ └── TreeCommand.ts # Repository tree viewer
237+
│ ├── cli/
238+
│ │ └── pr-command.ts # GitHub PR TUI launcher
239+
│ ├── core/
240+
│ │ └── GitService.ts # Git operations (simple-git wrapper)
241+
│ ├── services/
242+
│ │ ├── AIService.ts # Google Gemini integration
243+
│ │ ├── ConfigService.ts # Config load/save with Zod validation
244+
│ │ ├── ConflictResolver.ts
245+
│ │ └── GitHubService.ts # Octokit GitHub API client
246+
│ ├── ui/
247+
│ │ ├── PRList.tsx # Ink/React TUI component
248+
│ │ └── TreeUI.tsx
249+
│ └── utils/
250+
│ └── logger.ts # Pino structured logger
251+
├── package.json
252+
├── tsconfig.json
253+
└── LICENSE
254+
```
255+
256+
---
257+
258+
## Development Setup
259+
260+
```bash
261+
# Clone the repository
262+
git clone https://github.com/BeyteFlow/git-ai.git
263+
cd git-ai/git-ai
264+
265+
# Install dependencies
266+
npm install
267+
268+
# Run in development mode (no build step needed)
269+
npm run dev -- commit
270+
```
271+
272+
Available scripts:
273+
274+
| Script | Description |
275+
|--------|-------------|
276+
| `npm run dev` | Run from source with `tsx` (no compile step) |
277+
| `npm run build` | Compile TypeScript to `dist/` |
278+
| `npm run lint` | Type-check with `tsc --noEmit` |
279+
| `npm test` | Run linter (type-check) |
280+
281+
---
282+
283+
## Testing
284+
285+
Type-checking acts as the current test gate:
286+
287+
```bash
288+
npm test
289+
```
290+
291+
To manually exercise a command during development:
292+
293+
```bash
294+
# Run commit command without building first
295+
npm run dev -- commit
296+
297+
# Run init command
298+
npm run dev -- init
299+
```
300+
301+
---
302+
303+
## Roadmap
304+
305+
- [ ] OpenAI / GPT-4o support (`provider: "openai"`)
306+
- [ ] Conventional Commits format enforcement
307+
- [ ] `ai-git log` — AI-summarized git log
308+
- [ ] `ai-git review` — AI inline code review before push
309+
- [ ] Plugin system for custom AI providers
310+
- [ ] Shell completions (bash / zsh / fish)
311+
312+
---
313+
314+
## Contributing
315+
316+
Contributions are welcome! Please follow these steps:
317+
318+
1. **Fork** the repository and create a feature branch:
319+
```bash
320+
git checkout -b feat/your-feature
321+
```
322+
2. Make your changes, ensuring `npm test` passes.
323+
3. Commit using [Conventional Commits](https://www.conventionalcommits.org/):
324+
```bash
325+
git commit -m "feat(commit): add --dry-run flag"
326+
```
327+
4. Open a Pull Request against `main` with a clear description.
328+
329+
Please open an issue first for major changes or new features to discuss the approach.
330+
331+
---
332+
333+
## License
334+
335+
[MIT](LICENSE) © 2026 [BeyteFlow](https://github.com/BeyteFlow)
336+
337+
---
338+
339+
## Acknowledgements
340+
341+
- [Google Generative AI](https://ai.google.dev/) — Gemini API powering AI features
342+
- [Ink](https://github.com/vadimdemedes/ink) — React-based terminal UI framework
343+
- [Commander.js](https://github.com/tj/commander.js/) — CLI argument parsing
344+
- [simple-git](https://github.com/steveukx/git-js) — Fluent Git interface for Node.js
345+
- [Zod](https://zod.dev/) — TypeScript-first schema validation

0 commit comments

Comments
 (0)