{"id":34903452,"url":"https://github.com/huseynovvusal/gitai","last_synced_at":"2026-03-18T00:38:20.248Z","repository":{"id":316693282,"uuid":"1063099917","full_name":"huseynovvusal/gitai","owner":"huseynovvusal","description":"🤖 AI-powered Git CLI assistant built with Go. Automate commit messages, enforce pre-commit policies, detect secrets, and improve code quality with LLM-based suggestions.","archived":false,"fork":false,"pushed_at":"2025-10-12T18:49:45.000Z","size":14744,"stargazers_count":15,"open_issues_count":9,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-18T21:45:49.426Z","etag":null,"topics":["ai","assistant","cli","gemini","git","golang","gpt","hacktoberfest","llm","ollama","open-source","openai","pre-commit","tool","tui"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huseynovvusal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-24T07:00:02.000Z","updated_at":"2025-10-14T10:16:11.000Z","dependencies_parsed_at":"2025-09-26T06:23:49.397Z","dependency_job_id":"3d951d61-4812-4842-9ad5-f9fa7ca9f873","html_url":"https://github.com/huseynovvusal/gitai","commit_stats":null,"previous_names":["huseynovvusal/gitai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huseynovvusal/gitai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fgitai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fgitai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fgitai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fgitai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huseynovvusal","download_url":"https://codeload.github.com/huseynovvusal/gitai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fgitai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28050905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","assistant","cli","gemini","git","golang","gpt","hacktoberfest","llm","ollama","open-source","openai","pre-commit","tool","tui"],"created_at":"2025-12-26T09:13:08.930Z","updated_at":"2026-03-18T00:38:20.236Z","avatar_url":"https://github.com/huseynovvusal.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 **Gitai** — AI-powered Git Assistant\n\nGitai is an open-source CLI tool that helps developers generate **high-quality git commit messages** using AI. It inspects repository changes (diff + status) and provides concise, actionable suggestions via an interactive TUI.\n\nBelow is a quick animated demo of gitai running in a terminal:\n\n![Gitai usage demo](./assets/usage.gif)\n\nThe project supports multiple AI backends (OpenAI, Google Gemini via genai, and local models via Ollama) and is intended to be used as a developer helper (interactive CLI, pre-commit hooks, CI helpers).\n\n## ✨ Key features\n\n- **AI-generated commit message suggestions** based on repo diffs\n- _Interactive TUI_ to select files and review suggestions 🖱️\n- **Edit \u0026 Regenerate**: Tweak suggestions in-place or regenerate them with a keystroke 🔄\n- Pluggable AI backends: OpenAI, Google GenAI, Ollama (local)\n- Small single-binary distribution (Go) ⚙️\n\n## ⚡️ Quick start\n\n### 🛠️ Prerequisites\n\n- Go 1.20+ (Go modules are used; CONTRIBUTING recommends Go 1.24+ for development)\n- One of the supported AI providers (optional):\n  - OpenAI API key (OPENAI_API_KEY)\n  - Google API key for genai (GOOGLE_API_KEY)\n  - Ollama binary available and OLLAMA_API_PATH set (for local models)\n  - Gemini cli installed\n\n### 📦 Build and install\n\n1. Clone the repository and build:\n\n```sh\ngit clone https://github.com/yourusername/gitai.git\ncd gitai\nmake build\n```\n\n1. Install (**recommended**)\n\n```sh\nmake install\n# or if you want to personalize the keywords for the safety check of your diff\nmake install-personalized-keys \"comma,separated,keys\"\n```\n\nThe `make install` target builds the `gitai` binary and moves it to `/usr/local/bin/` (may prompt for sudo). Alternatively copy `./bin/gitai` to a directory in your PATH.\n\n### ▶️ Run (example)\n\nGenerate commit message suggestions using the _interactive TUI_:\n\n```sh\ngitai suggest\n```\n\nSelecting AI provider (flag or env)\n\nYou can choose which AI backend to use with a flag or environment variable. The `--provider` flag overrides the env var for that run.\n\n```sh\n# use local Ollama via flag\ngitai suggest --provider=ollama\n\n# use OpenAI GPT\ngitai suggest --provider=gpt\n\n# use Gemini\ngitai suggest --provider=gemini\n\n\n# use Gemini cli\ngitai suggest --provider=gemini_cli\n```\n\n`gitai suggest` will:\n\n- list changed files (using `git status --porcelain`)\n- allow selecting files via an interactive file selector\n- fetch diffs for selected files and call the configured AI backend to produce suggestions\n- allow editing the suggestion (press `e`) or regenerating it (press `r`)\n\nSee `internal/tui/suggest` for the implementation of the flow.\n\n## 🔧 Configuration\n\nConfiguration is managed with Viper and can be provided from, in order of precedence (highest first):\n\n1. CLI flags\n2. Environment variables\n3. Config files\n4. Built-in defaults\n\nYou can mix and match; higher‑precedence sources override lower ones.\n\nSupported keys\n- ai.provider: Which backend to use. Options: gpt, gemini, ollama, geminicli\n  - Flag: --provider or -p\n  - Env: GITAI_AI_PROVIDER\n  - Config key: ai.provider\n- ai.api_key: API key for the chosen backend\n  - Flag: --api_key or -k\n  - Env: GITAI_AI_API_KEY or GITAI_API_KEY\n  - Provider fallbacks (legacy):\n    - OpenAI: OPENAI_API_KEY\n    - Gemini: GOOGLE_API_KEY\n- ollama.path: Path to the Ollama binary when provider=ollama\n  - Env: OLLAMA_API_PATH\n  - Config key: ollama.path\n- suggest.editor: Which editor to use for editing commit messages. Options: system, internal, or a command (e.g. \"nano\", \"code -w\")\n  - Flag: --editor or -e\n  - Config key: suggest.editor\n  - Default: system (uses $EDITOR/$VISUAL)\n\nConfig files\n- Base name: gitai (no extension in code). Viper will load any supported format found (e.g., gitai.yaml, gitai.yml, gitai.json, etc.).\n- Search paths (in this order):\n  1) /etc/gitai/\n  2) $HOME/.config/gitai/\n  3) $HOME/.gitai/\n  4) Current Git root directory \n  5) Current working directory (.)\n\nExample gitai.yaml\n```yaml\nai:\n  provider: gpt     # gpt | gemini | ollama | geminicli\n  api_key: \"sk-...\" # Optional here; can be provided via env/flag\n\n# Only needed if you use provider=ollama\nollama:\n  path: \"/usr/local/bin/ollama\"\n\nsuggest:\n  editor: builtin # Use the built-in TUI editor\n```\nExample gitai.json\n```json\n{\n  \"ai\": {\n    \"provider\": \"gpt\",\n    \"api_key\": \"sk-...\"\n  },\n  \"ollama\": {\n    \"path\": \"/usr/local/bin/ollama\"\n  },\n  \"suggest\": {\n    \"editor\": \"builtin\"\n  }\n}\n```\n\nExamples\n- Use local Ollama via flag:\n  - `gitai suggest --provider=ollama`\n- Use OpenAI with env var:\n  - ```export GITAI_AI_API_KEY=\"sk-...\"```\n  - ```gitai suggest --provider=gpt```\n- Use builtin editor:\n  - `gitai suggest --editor=builtin`\n- Use custom editor command:\n  - `gitai suggest --editor=\"code -w\"`\n- Use config file only:\n  - Create the gitai file in any of the supported search paths\n  - `gitai suggest`\n\nNotes\n- If multiple sources set the same key, flags win over env; env wins over config files.\n- For CI, prefer environment variables (GITAI_AI_PROVIDER, GITAI_AI_API_KEY) to avoid committing secrets.\n- OPENAI_API_KEY and GOOGLE_API_KEY are respected as fallbacks when using those providers.\n\n## 🧩 How it works (internals)\n\nCore components live under `internal/`:\n\n- `internal/ai` — adapters for AI backends and the main prompt (`GenerateCommitMessage`)\n- `internal/git` — helpers that run git commands and parse diffs/status (helpers used by the TUI)\n- `internal/tui/suggest` — TUI flow (file selector → AI message view)\n\nThe entrypoint is `main.go` which dispatches to the Cobra-based CLI under `cmd/`.\n\n## 🧑‍💻 Development\n\nTo run locally while developing:\n\n1. Ensure Go is installed and `GOPATH`/`GOMOD` are configured (this repo uses Go modules).\n2. Run the CLI directly from source:\n\n```sh\ngo run ./main.go suggest\n```\n\n### 🧪 Running unit tests\n\nIf tests are added, run them with:\n\n```sh\ngo test ./...\n```\n\n### ➕ Adding a new AI backend\n\n1. Add a new adapter under `internal/ai` that implements a function returning (string, error).\n2. Wire it into `GenerateCommitMessage` or create a configuration switch.\n\n## Star History\n\n\u003ca href=\"https://www.star-history.com/#huseynovvusal/gitai\u0026Date\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=huseynovvusal/gitai\u0026type=Date\u0026theme=dark\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=huseynovvusal/gitai\u0026type=Date\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=huseynovvusal/gitai\u0026type=Date\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n## 🤝 Contributing\n\nContributions are welcome. Please follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md).\n\nSuggested contribution workflow:\n\n1. Fork the repo and create a topic branch\n2. Implement your feature or fix\n3. Add/adjust tests where appropriate\n4. Open a pull request describing the change and rationale\n\nIf you'd like help designing an enhancement (hooks, CI integrations, new backends), open an issue first to discuss.\n\n## 🔒 Security \u0026 Privacy\n\n- The tool may send diffs and repository content to third-party AI providers when generating messages — treat this like any other service that may upload code. Do not send secrets or sensitive data to remote AI providers.\n- If you need an offline-only workflow, prefer running local models via Ollama and keep `OLLAMA_API_PATH` configured.\n\n## 📜 License\n\nThis project is released under the MIT License. See [LICENSE](LICENSE) for details.\n\n## 👤 Authors\n\nVusal Huseynov — original author\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuseynovvusal%2Fgitai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuseynovvusal%2Fgitai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuseynovvusal%2Fgitai/lists"}