Skip to content
barunTayenjamPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

AIC - AI Git Helper Plugin

🤖 An intelligent Zsh plugin that automates your Git workflow using AI-powered commit messages and optional conflict resolution — now with multi‑provider OpenAI‑compatible REST, Node/curl fallback, and one‑file setup.

What’s new (v2.0.0)

  • Removed Python dependency entirely
  • Added multi‑provider support (OpenAI‑compatible endpoints): Mistral, Groq, OpenAI, Together, Anyscale, or custom
  • Preferred transport: Node 18+ fetch; fallback transport: pure curl (with optional jq for parsing)
  • Simple setup: edit the plugin file itself to add your provider, API key, and (optional) endpoint/model
  • Non‑interactive mode for CI and headless environments
  • Works from any subdirectory in your Git repo

Features

  • 🪄 AI‑Generated Commit Messages with architecture‑level detail
  • 🗂️ Auto‑Staging: stages all changes
  • 🔄 Full Workflow: stage → AI message → commit → pull (safe) → optional resolve → push
  • ⚔️ Conflict Resolution (optional AI assist)
  • 📍 Directory Agnostic: run from any subdirectory within a Git repo
  • 🌐 Multi‑Provider via OpenAI‑compatible REST
  • 🧰 Node 18+ or curl‑only fallback (no extra packages)
  • ⌨️ Keyboard Shortcut: Ctrl‑X, A
  • 🛡️ Unicode‑safe diff handling and robust fallbacks

Prerequisites

  • Zsh shell (Oh My Zsh recommended)
  • Git
  • curl
  • Optional but recommended: Node 18+ (built‑in fetch), jq (better JSON parsing in curl fallback)

Quick Setup (Recommended)

# 1) Create the plugin directory
mkdir -p ~/.oh-my-zsh/custom/plugins/aic

# 2) Download the plugin file
curl -o ~/.oh-my-zsh/custom/plugins/aic/aic.plugin.zsh \
  https://raw.githubusercontent.com/YOUR_ORG_OR_USER/aic-plugin/main/aic.plugin.zsh

# 3) Enable the plugin in ~/.zshrc
# Add 'aic' to your plugins list
# plugins=(git aic other-plugins...)

# 4) Reload shell
source ~/.zshrc

# 5) Configure provider and API key by editing the plugin file
nano ~/.oh-my-zsh/custom/plugins/aic/aic.plugin.zsh
# Find the section: "USER CONFIG (edit me)"
# Fill in AIC_PROVIDER_DEFAULT, AIC_API_KEY_DEFAULT, and optionally AIC_BASE_URL_DEFAULT / AIC_MODEL_DEFAULT

# 6) Use the plugin
cd /path/to/your/repo
# Make some changes, then run:
aic

Provider Examples

  • Mistral (default)
    • USER CONFIG:
      • AIC_PROVIDER_DEFAULT="mistral"
      • AIC_API_KEY_DEFAULT="mis_xxx"
      • AIC_MODEL_DEFAULT="mistral-small-latest" (optional; default is set automatically)
  • Groq
    • USER CONFIG:
      • AIC_PROVIDER_DEFAULT="groq"
      • AIC_API_KEY_DEFAULT="sk_groq_xxx"
      • AIC_MODEL_DEFAULT="llama-3.1-70b-versatile"
  • OpenAI
    • USER CONFIG:
      • AIC_PROVIDER_DEFAULT="openai"
      • AIC_API_KEY_DEFAULT="sk-openai-xxx"
      • (set AIC_MODEL_DEFAULT to your chosen model)
  • Custom endpoint

Environment variables still work and override USER CONFIG when set:

  • AIC_PROVIDER, AIC_API_KEY, AIC_BASE_URL, AIC_MODEL
  • Provider‑specific keys also supported: GROQ_API_KEY, OPENAI_API_KEY, MISTRAL_API_KEY

Configuration Precedence

  1. Environment variables (AIC_PROVIDER, AIC_API_KEY, AIC_BASE_URL, AIC_MODEL)
  2. Plugin file USER CONFIG block
  3. Provider defaults (base URLs and common models)
  4. For Mistral only: ~/.config/mistral/api_key as a last resort

Usage

  • From any directory inside a Git repository, run:
aic
  • Keyboard shortcut: Ctrl‑X, A

What it does:

  1. Validates basic environment (git, curl, optional node/jq)
  2. Detects repo root and stages all changes
  3. Builds a diff or a summarized prompt for large changes
  4. Calls your configured AI provider (Node fetch if available; otherwise curl)
  5. Shows the proposed commit message for confirmation
  6. Commits, pulls safely (rebase‑first), resolves conflicts if requested, and pushes

Non‑Interactive / CI Mode

  • Set AIC_NON_INTERACTIVE=1 (or AIC_ASSUME_YES=1) to auto‑accept prompts.
  • In non‑interactive mode:
    • Pre‑flight warnings auto‑continue
    • Commit confirmation auto‑accepts the AI message
    • Push failures do not abort (they log and continue)

Troubleshooting

  • "Not a Git repository"
    • Run aic from inside a Git repo. The plugin runs fine from any subdirectory.
  • "API key is not configured"
    • Fill in the USER CONFIG block in the plugin file, or set AIC_API_KEY.
  • Provider/Model errors
    • Ensure AIC_MODEL is valid for your provider. Try a known working model first.
  • No internet
    • The plugin falls back to a simple commit message.
  • Node vs curl
    • Node 18+ is preferred. Without Node, the plugin uses curl‑only fallback. jq helps parse responses when available.
  • Push fails: "No configured push destination"
    • Add a remote origin or ignore in non‑interactive mode.
  • Zsh keybindings not applied
    • Bindings use zle; they apply in interactive Zsh. The command still works without them.

Security Notes

  • Never commit real API keys into version control.
  • If you paste a key into the plugin file, keep this file out of version control or store keys via environment variables.
  • Consider per‑user config via env vars for shared repos.

Performance Notes

  • Uses prompt summarization for large changes (line‑based threshold)
  • Works with binary/unicode‑heavy diffs via robust handling
  • Typical AI call overhead: depends on provider/model

Changelog

v2.0.0 (Current)

  • Removed Python, adoption of multi‑provider OpenAI‑compatible REST
  • Node 18+ fetch (preferred) with curl‑only fallback
  • USER CONFIG block for easy setup in the plugin file
  • Non‑interactive mode retained and improved

v1.x (Legacy)

  • Python/mistralai SDK, single‑provider design

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages