Skip to main content

AI-powered Git assistant with persistent context management

Project description

GitAgent - Unified AI-Powered Git Assistant

GitAgent is a unified AI-powered Git assistant that provides intelligent, context-aware Git operations with persistent session management and automatic command verification.

๐Ÿš€ Key Features

๐Ÿง  Unified Intelligence

  • No more basic/advanced modes - All features unified in one intelligent system
  • Context-aware command recommendations based on repository state
  • Natural language understanding for complex Git operations

๐Ÿ“ Persistent Context Management

  • Session persistence across multiple invocations
  • Workflow resumption for interrupted operations
  • Command history and verification tracking
  • Sessions stored in .git/gitagent_sessions/ for full context preservation

โœ… Advanced Command Verification

  • Automatic success verification after each command execution
  • Semantic verification beyond just error codes
  • Intelligent error recovery with specific issue identification
  • Pre-execution prerequisite checking

๐Ÿ”„ Multi-Step Workflow Management

  • Intelligent workflow decomposition for complex operations
  • Step-by-step execution with user confirmation
  • Context preservation across workflow steps
  • Automatic workflow completion tracking

โšก Automation Ready

  • Auto-approve mode (-y flag) for scripts and CI/CD
  • Full verification even in automated mode
  • Detailed execution logging and result tracking

๐Ÿ› ๏ธ Installation

  1. Clone the repository:

    git clone <repository-url>
    cd GitAgent
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Make the script executable:

    chmod +x gitagent
    
  4. Set up your Groq API key (required for AI functionality):

    export GROQ_API_KEY="your-groq-api-key"
    

๐Ÿ“– Usage

Basic Usage

# Interactive mode - ask any Git question
./gitagent "What's the current status of my repository?"

# Multi-step operations
./gitagent "Stage all changes, commit with a meaningful message, and push to origin"

# Branch operations  
./gitagent "Delete current branch and create a new feature branch called user-auth"

Auto-Approve Mode (for automation)

# Automatically approve all recommended commands
./gitagent -y "Stage and commit all changes"

# Perfect for scripts and CI/CD pipelines
./gitagent -y "Push all commits to origin main"

Session Management

# Resume interrupted workflows
./gitagent continue

# Or just run any command - GitAgent will detect and offer to resume active sessions
./gitagent "What should I do next?"

Help and Options

./gitagent --help

๐ŸŽฏ Example Workflows

1. Smart Repository Analysis

./gitagent "Analyze my repository and tell me what needs attention"
  • Analyzes current status, uncommitted changes, unpushed commits
  • Provides context-aware recommendations
  • Remembers previous analysis for comparison

2. Complex Branch Operations

./gitagent "I want to delete this feature branch and create a new one for bug fixes"
  • Automatically switches to safe branch before deletion
  • Verifies branch deletion success
  • Creates new branch with proper base
  • Tracks entire workflow in session

3. Commit Workflow Automation

./gitagent -y "Stage modified files, create commit with descriptive message, and push"
  • Intelligently stages appropriate files
  • Generates meaningful commit messages
  • Handles push with proper upstream tracking
  • Verifies each step's success

4. Error Recovery

# If something goes wrong, GitAgent can help recover
./gitagent "The last command failed, what should I do?"
  • Analyzes failure context from session history
  • Provides specific recovery steps
  • Can resume workflow after fixes

๐Ÿ”ง Architecture

Unified Agent Design

  • Single LangGraph workflow handles all scenarios
  • State management with persistent sessions
  • Command verification at each step
  • Intelligent routing based on context and intent

Session Persistence

  • Sessions stored as JSON in .git/gitagent_sessions/
  • Full command history with verification results
  • Workflow context and step tracking
  • Resumable across GitAgent invocations

Verification System

  • Pre-execution prerequisite checking
  • Post-execution state verification
  • Semantic validation of command outcomes
  • Detailed error reporting with recovery suggestions

๐Ÿ“‚ Project Structure

GitAgent/
โ”œโ”€โ”€ git_agent_langgraph.py    # Main unified agent implementation
โ”œโ”€โ”€ gitagent                  # Executable script
โ”œโ”€โ”€ main.py                   # Alternative entry point
โ”œโ”€โ”€ demo.py                   # Interactive demonstration
โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ git_service.py        # Legacy service (deprecated)
โ”‚   โ””โ”€โ”€ groq_api_service.py   # AI service integration
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ git_commands.py       # Git command execution utilities
โ”‚   โ”œโ”€โ”€ input_handler.py      # User interaction handling
โ”‚   โ””โ”€โ”€ streaming.py          # Output formatting utilities
โ””โ”€โ”€ controllers/              # Legacy controllers (deprecated)

๐Ÿš€ What's New in Unified Version

โœ… Fixed Issues

  • Context persistence - No more losing context between steps
  • Execution tracking - Full visibility into what worked/failed
  • Session management - Resume interrupted workflows
  • Command verification - Reliable success/failure detection
  • Unified experience - No confusion between basic/advanced modes

๐Ÿ†• New Capabilities

  • Intelligent workflow decomposition for complex requests
  • Automatic error recovery with specific guidance
  • Session-based context that survives interruptions
  • Advanced verification beyond simple error checking
  • Production-ready automation with auto-approve mode

๐Ÿ” Demo

Run the interactive demo to see all features:

python demo.py

The demo showcases:

  • Context-aware information queries
  • Multi-step workflow management
  • Session persistence and resumption
  • Command verification in action
  • Auto-approve mode for automation

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

If you encounter any issues or have questions:

  1. Check the demo for usage examples
  2. Run ./gitagent --help for options
  3. Look in .git/gitagent_sessions/ for session logs
  4. Open an issue with session details for debugging

GitAgent Unified - Intelligent Git assistance with persistent context and reliable execution tracking.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitagent_ai-1.0.0.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitagent_ai-1.0.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file gitagent_ai-1.0.0.tar.gz.

File metadata

  • Download URL: gitagent_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for gitagent_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e9cad27f63da41d2bfb7fd543b45829f4bde97fab77df331ed760eb0f450761
MD5 ff010cf9f9717d74ebc88aa41b7f3620
BLAKE2b-256 0d9b413d054bd1f663d5ea843f81b527b81399fc5e0968945edca37ae0b2c6dc

See more details on using hashes here.

File details

Details for the file gitagent_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gitagent_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for gitagent_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35d217d35fd04d9761e20b90ab3a488b1e557bb1c527427726edfa7d6fafd7db
MD5 17bc4e8759bb50c1b4c9f18ccf4aad15
BLAKE2b-256 d8ae268ce31e333e08761ea8e8a718fd02e3e53822598517c780ff2d8f6f01a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page