Skip to content

codeWithUtkarsh/AiAgentToolCalling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Agent Tool Calling - Automated Dependency Update System

A multi-agent Python system that uses LangChain's tool calling pattern to automatically update dependencies with intelligent testing and rollback capabilities. It analyzes repositories, updates dependencies, tests the changes, rolls back breaking updates, and creates Pull Requests or Issues automatically.

🌟 Features

Core Capabilities

  • πŸ€– Fully Automated Updates: End-to-end automation from analysis to PR creation
  • πŸ§ͺ Intelligent Testing: Automatically runs build/test commands to verify updates
  • πŸ”™ Smart Rollback: Identifies breaking changes and rolls back only problematic major updates
  • βœ… Auto PR Creation: Creates GitHub Pull Requests with successful updates
  • πŸ”΄ Auto Issue Creation: Creates GitHub Issues when updates can't be applied safely
  • πŸ“Š Multi-Agent Architecture: Orchestrator pattern with specialized sub-agents
  • 🧠 AI-Powered Analysis: Uses Claude to analyze errors and identify problematic dependencies

Language Support

Detects and updates dependencies for:

  • JavaScript/Node.js (npm, yarn, pnpm)
  • Python (pip, pipenv, poetry)
  • Rust (cargo)
  • Ruby (bundler)
  • Java (Maven, Gradle)
  • PHP (Composer)
  • Go (go modules)

Smart Features

  • Automatic Build Detection: Detects how to build, test, and verify your project
  • Error Analysis: AI-powered parsing of error messages to identify culprits
  • Iterative Rollback: Tries to salvage as many updates as possible
  • Version Categorization: Categorizes updates as major/minor/patch
  • Comprehensive Reporting: Detailed PR descriptions with what was updated and why

πŸ—οΈ Architecture

This project implements a multi-agent system following the LangChain Tool Calling pattern:

Agent Hierarchy

auto_update_dependencies.py (Main Orchestrator)
β”œβ”€β”€ dependency_analyzer.py (Analysis Agent)
β”‚   └── Tools: clone, detect, check outdated
β”œβ”€β”€ smart_dependency_updater.py (Smart Update Agent)
β”‚   β”œβ”€β”€ Tools: detect build, test, write files, git ops
β”‚   └── Sub-tools: apply updates, rollback, parse errors
└── dependency_operations.py (Helper Tools)
    └── Tools: categorize, version lookup, error analysis

Complete Workflow Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  USER INPUT: Repository URL                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  STEP 1: ANALYZE REPOSITORY                                 β”‚
β”‚  β€’ Clone repository                                          β”‚
β”‚  β€’ Detect package manager                                    β”‚
β”‚  β€’ Find outdated dependencies                                β”‚
β”‚  β€’ Categorize: major/minor/patch                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  STEP 2: APPLY ALL UPDATES                                  β”‚
β”‚  β€’ Update ALL dependencies to latest                         β”‚
β”‚  β€’ Including major version updates                           β”‚
β”‚  β€’ Write updated dependency files                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  STEP 3: TEST UPDATES                                       β”‚
β”‚  β€’ Run install command                                       β”‚
β”‚  β€’ Run build command                                         β”‚
β”‚  β€’ Run test command                                          β”‚
β”‚  β€’ Capture all output                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                   β”‚
         Tests Pass?         Tests Fail?
                β”‚                   β”‚
                β–Ό                   β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚ CREATE PR      β”‚  β”‚ ANALYZE ERROR              β”‚
       β”‚                β”‚  β”‚ β€’ Use AI to parse errors   β”‚
       β”‚ β€’ Git branch   β”‚  β”‚ β€’ Identify problematic pkg β”‚
       β”‚ β€’ Commit       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ β€’ Push         β”‚              β”‚
       β”‚ β€’ gh pr create β”‚              β–Ό
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚          β”‚ ROLLBACK MAJOR UPDATE      β”‚
                β”‚          β”‚ β€’ Find latest in major ver β”‚
                β”‚          β”‚ β€’ Update dependency file   β”‚
                β”‚          β”‚ β€’ Write file               β”‚
                β”‚          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚                      β”‚
                β”‚                      β–Ό
                β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚          β”‚ TEST AGAIN (Max 3x)        β”‚
                β”‚          β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                β”‚              β”‚                  β”‚
                β”‚         Now Pass?          Still Fail?
                β”‚              β”‚                  β”‚
                β”‚              └──────┐    β”Œβ”€β”€β”€β”€β”€β”€β”˜
                β”‚                     β”‚    β”‚
                β–Ό                     β–Ό    β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚ SUCCESS!       β”‚  β”‚ CREATE ISSUE             β”‚
       β”‚ PR Created     β”‚  β”‚ β€’ Document what failed   β”‚
       β”‚                β”‚  β”‚ β€’ Include error logs     β”‚
       β”‚ Output:        β”‚  β”‚ β€’ Tag: dependencies      β”‚
       β”‚ β€’ PR URL       β”‚  β”‚                          β”‚
       β”‚ β€’ Summary      β”‚  β”‚ Output:                  β”‚
       β”‚ β€’ Rollbacks    β”‚  β”‚ β€’ Issue URL              β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β€’ Failure details        β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1. Auto Update Orchestrator (Main Entry Point)

Main coordinator (auto_update_dependencies.py) that manages the complete workflow:

  • Receives repository URL or name
  • Checks prerequisites (Docker, GitHub token)
  • Orchestrates analysis and update agents
  • Manages end-to-end automated updates with PR/Issue creation

Functions:

  • analyze_repository() - Invokes the analyzer agent
  • smart_update_and_test() - Invokes the smart updater agent
  • Docker and GitHub token validation

2. Dependency Analyzer Agent (Analysis)

Specialized in finding outdated dependencies (dependency_analyzer.py):

  • Clones repositories
  • Detects package managers
  • Identifies outdated packages
  • Returns structured analysis reports

Tools:

  • clone_repository - Clones git repos to temp directories
  • detect_package_manager - Identifies package managers and config files
  • read_dependency_file - Reads dependency configuration files
  • check_npm_outdated - Checks outdated npm packages
  • check_pip_outdated - Checks outdated Python packages (via PyPI API)
  • cleanup_repository - Removes temporary files

3. Smart Dependency Updater Agent (Update & Test)

Specialized in updating with intelligent testing and rollback (smart_dependency_updater.py):

  • Applies dependency updates
  • Runs build and test commands
  • Automatically rolls back breaking changes
  • Creates GitHub PRs on success
  • Creates GitHub Issues on failure

Tools:

  • detect_build_command - Auto-detects build/test commands
  • apply_updates - Updates dependency files
  • test_updates - Runs build/test commands
  • rollback_major_update - Rolls back problematic updates
  • create_github_pr - Creates PRs using MCP
  • create_github_issue - Creates issues using MCP
  • parse_error_for_dependency - AI-powered error analysis

4. Dependency Operations (Helper Module)

Utility functions for dependency manipulation (dependency_operations.py):

  • Applies updates to various dependency file formats
  • Rolls back specific package updates
  • Categorizes updates (major/minor/patch)
  • Finds latest versions within major releases

Functions:

  • apply_all_updates() - Applies all updates to dependency files
  • rollback_major_update() - Rolls back specific package versions
  • parse_error_for_dependency() - AI analysis of build errors
  • categorize_updates() - Categorizes updates by type
  • get_latest_version_for_major() - Finds latest version in major release

πŸ“¦ Installation

Prerequisites

  • Python 3.8 or higher
  • Git
  • Node.js and npm (for checking npm packages)
  • pip (for checking Python packages)
  • Other package managers as needed (cargo, go, etc.)

Setup

  1. Clone this repository:
git clone https://github.com/codeWithUtkarsh/AiAgentToolCalling.git
cd AiAgentToolCalling
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Set up your Anthropic API key:
export ANTHROPIC_API_KEY='your-api-key-here'

Or create a .env file (copy from .env.example):

cp .env.example .env
# Edit .env and add your API key

GitHub MCP Setup (Required for PR/Issue Creation)

The system uses GitHub MCP (Model Context Protocol) to create Pull Requests and Issues automatically.

Prerequisites

  1. Container Runtime (Docker, OrbStack, Podman, etc.)

  2. GitHub Personal Access Token

Setup Steps

1. Install Container Runtime (if not already installed)

macOS (choose one):

# Option 1: OrbStack (recommended - lightweight and fast)
brew install orbstack

# Option 2: Docker Desktop
# Download from https://www.docker.com/products/docker-desktop

2. Fix PATH for macOS/OrbStack Users

If you're on macOS and encounter "docker: command not found" errors in Python:

# Add to your shell configuration
echo 'export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

For bash users:

echo 'export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

3. Set GitHub Token

export GITHUB_PERSONAL_ACCESS_TOKEN='your_github_token_here'

To make it permanent:

# For zsh (macOS default)
echo 'export GITHUB_PERSONAL_ACCESS_TOKEN="your_token"' >> ~/.zshrc
source ~/.zshrc

# For bash
echo 'export GITHUB_PERSONAL_ACCESS_TOKEN="your_token"' >> ~/.bash_profile
source ~/.bash_profile

4. Verify Setup

Test your GitHub MCP setup:

python diagnose_github_mcp.py

Expected output:

βœ… Container runtime: PASS
βœ… GitHub token: PASS
βœ… MCP connection: PASS
βœ… MCP tool call: PASS

If any tests fail, the diagnostic tool will show specific instructions to fix the issue.

Supported Container Runtimes

The system automatically detects and works with:

  • Docker Desktop - Official Docker
  • OrbStack - Lightweight Docker alternative for macOS
  • Podman Desktop - Daemonless container engine
  • Rancher Desktop - Kubernetes + containers

No configuration needed - it auto-detects which one you have installed!

πŸš€ Usage

Automated Update with Testing (New! Recommended)

The fully automated system that updates dependencies, tests them, and creates PRs:

python auto_update_dependencies.py <repository>

Examples:

# Using full URL
python auto_update_dependencies.py https://github.com/expressjs/express

# Using owner/repo format
python auto_update_dependencies.py expressjs/express

What it does:

  1. πŸ“Š Clones and analyzes your repository
  2. πŸ”„ Updates all dependencies to latest (including major versions)
  3. πŸ§ͺ Runs build and test commands
  4. πŸ”™ If tests fail: identifies problematic packages and rolls back major updates
  5. βœ… Creates a Pull Request if successful
  6. πŸ”΄ Creates an Issue if updates can't be applied safely

Prerequisites:

  • Docker installed and running: docker --version
  • GitHub Personal Access Token set: export GITHUB_PERSONAL_ACCESS_TOKEN='your_token'
  • Git push access to the repository
  • Package manager tools installed (npm, pip, cargo, etc.)

πŸ“Š Sample Workflows

Workflow 1: Successful Update with Rollback

Repository: myapp (Node.js project)

πŸ“Š Analysis found 10 outdated packages:
  - express: 4.17.0 β†’ 5.0.0 (MAJOR)
  - lodash: 4.17.20 β†’ 4.17.21 (PATCH)
  - react: 17.0.0 β†’ 18.2.0 (MAJOR)
  - axios: 0.21.0 β†’ 1.6.0 (MAJOR)
  ... 6 more

πŸ”„ Applying all updates...
βœ… Updated package.json

πŸ§ͺ Testing updates...
  ❌ npm test failed

πŸ” Analyzing error...
  Identified: React 18 breaking change in test utilities

πŸ”™ Rolling back React 18 β†’ 17...
  Finding latest React 17.x: 17.0.2
  βœ… Rolled back to react@17.0.2

πŸ§ͺ Testing again...
  βœ… npm install - success
  βœ… npm run build - success
  βœ… npm test - success

βœ… Creating Pull Request...
  Branch: deps/auto-update-20250126
  PR: https://github.com/owner/myapp/pull/123

RESULT:
βœ… Successfully updated 10 dependencies!
  - Applied 9 updates to latest versions
  - Rolled back React 18.2.0 β†’ 17.0.2 (breaking changes)
  - All tests passing

πŸ“ PR Summary:
  - express 4.17.0 β†’ 5.0.0 βœ…
  - lodash 4.17.20 β†’ 4.17.21 βœ…
  - react 17.0.0 β†’ 17.0.2 (rolled back from 18.2.0)
  - axios 0.21.0 β†’ 1.6.0 βœ…
  - ... 6 more βœ…

Workflow 2: Failed Update (Issue Created)

Repository: legacy-app (Python project)

πŸ“Š Analysis found 5 outdated packages:
  - django: 2.2 β†’ 4.2 (MAJOR)
  - requests: 2.25.0 β†’ 2.31.0 (MINOR)
  ... 3 more

πŸ”„ Applying all updates...
βœ… Updated requirements.txt

πŸ§ͺ Testing updates...
  ❌ pytest failed

πŸ” Analyzing error...
  Identified: Django 4.x breaking changes in models

πŸ”™ Rolling back Django 4.2 β†’ 2.2...
  Finding latest Django 2.x: 2.2.28
  βœ… Rolled back to Django 2.2.28

πŸ§ͺ Testing again...
  ❌ pytest still failing

πŸ” Analyzing error...
  Identified: Compatibility issues with Python version

πŸ”΄ Cannot apply updates safely

πŸ“‹ Creating Issue...
  Issue: https://github.com/owner/legacy-app/issues/45

RESULT:
❌ Updates could not be applied safely

Issue created with details:
  - Attempted updates to 5 packages
  - Django major update causes breaking changes
  - Python version compatibility issues detected
  - Manual review and migration needed

πŸ“Š Sample Output (Legacy Mode)

Orchestrator Agent Output

================================================================================
πŸ€– Dependency Update Agent
================================================================================

πŸ“¦ Repository: expressjs/express
πŸ”— URL: https://github.com/expressjs/express

πŸ“Š Running dependency analyzer on https://github.com/expressjs/express...

> Entering new AgentExecutor chain...
Cloning repository...
Repository cloned successfully

Detecting package managers...
Found: npm (package.json)

Checking outdated packages...
Found 8 outdated npm packages

================================================================================
βœ… FINAL REPORT
================================================================================

# πŸ”„ Dependency Updates for expressjs/express

## πŸ“¦ Updated Dependencies

### ⚠️ Major Updates
- πŸ”΄ **body-parser**: `1.19.0` β†’ `2.0.0` (MAJOR - may have breaking changes)

### Minor Updates
- 🟑 **cookie**: `0.4.1` β†’ `0.5.0` (minor)
- 🟑 **debug**: `2.6.9` β†’ `2.7.0` (minor)

### Patch Updates
- 🟒 **accepts**: `1.3.7` β†’ `1.3.8` (patch)
- 🟒 **etag**: `1.8.1` β†’ `1.8.2` (patch)

## πŸ§ͺ Testing Instructions

Please run the following commands to verify the updates:

```bash
# Install dependencies
npm install

# Run tests
npm test

# Run build
npm run build

# Check for issues
npm run lint

⚠️ Important Notes

  • ⚠️ This PR includes MAJOR version updates
  • Review changelogs for breaking changes
  • Run the full test suite before merging
  • Check for deprecation warnings
  • Verify build succeeds
  • Review any peer dependency warnings

πŸ“Š Total dependencies updated: 8 πŸ€– This PR was generated by the Dependency Update Agent


## πŸ”„ Workflow

The orchestrator agent follows this workflow:

1. **Analyze Dependencies**
   - Clone the repository
   - Detect package managers
   - Identify outdated dependencies
   - Generate analysis report

2. **Update Dependency Files**
   - Read current dependency files
   - Update version numbers
   - Preserve file formatting
   - Determine testing strategy

3. **Create PR Description**
   - Categorize updates (major/minor/patch)
   - Add testing instructions
   - Include warnings for breaking changes
   - Provide checklist

4. **Report Results**
   - Summary of updates
   - PR description ready to use
   - Next steps for the user

## πŸ› οΈ Extending the System

### Adding New Package Manager Support

1. **Update `dependency_analyzer.py`:**

Add detection in `detect_package_manager` tool:
```python
if os.path.exists(os.path.join(repo_path, "your-config-file")):
    package_managers["your-pm"] = {
        "files": ["your-config-file"],
        "lock_files": []
    }

Create a checking tool:

@tool
def check_yourpm_outdated(repo_path: str) -> str:
    """Check for outdated packages in your package manager."""
    # Implementation here
    pass
  1. Update dependency_operations.py:

Add update logic:

def apply_yourpm_updates(file_path: str, updates: list) -> bool:
    """Update your package manager config file."""
    # Implementation here
    pass
  1. Update smart_dependency_updater.py:

Add testing strategy in detect_build_command tool:

# Add detection for your package manager
if package_manager == "your-pm":
    return {
        "install": "your-pm install",
        "build": "your-pm build",
        "test": "your-pm test"
    }

πŸ” Agent Communication Flow

User Input (repo URL)
    ↓
Auto Update Orchestrator (auto_update_dependencies.py)
    ↓
    β”œβ”€ Check Prerequisites (Docker, GitHub Token)
    ↓
    β”œβ”€β†’ Dependency Analyzer Agent
    β”‚   β”œβ”€β†’ clone_repository
    β”‚   β”œβ”€β†’ detect_package_manager
    β”‚   β”œβ”€β†’ check_npm_outdated / check_pip_outdated
    β”‚   └─→ cleanup_repository
    β”‚   ↓
    β”‚   Returns: Analysis Report (outdated packages)
    ↓
    β”œβ”€β†’ Smart Dependency Updater Agent
    β”‚   β”œβ”€β†’ detect_build_command (auto-detect test commands)
    β”‚   β”œβ”€β†’ apply_updates (update dependency files)
    β”‚   β”œβ”€β†’ test_updates (run build/test)
    β”‚   β”œβ”€ If tests fail:
    β”‚   β”‚   β”œβ”€β†’ parse_error_for_dependency (AI error analysis)
    β”‚   β”‚   β”œβ”€β†’ rollback_major_update (rollback problematic package)
    β”‚   β”‚   └─→ test_updates (retry, max 3 attempts)
    β”‚   β”œβ”€ If tests pass:
    β”‚   β”‚   └─→ create_github_pr (via Docker MCP)
    β”‚   β”œβ”€ If tests still fail after rollbacks:
    β”‚   β”‚   └─→ create_github_issue (via Docker MCP)
    β”‚   ↓
    β”‚   Returns: PR URL or Issue URL
    ↓
Returns to User: Success (PR created) or Failure (Issue created)

πŸ”§ Using Different LLM Providers

The system currently uses Anthropic's Claude, but you can switch to OpenAI:

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4-turbo-preview", temperature=0)

Update all three agent files and set your OpenAI API key:

export OPENAI_API_KEY='your-api-key-here'

πŸ—‚οΈ Caching

The system includes smart caching to improve performance and reduce API calls:

How Caching Works

  • Repository Caching: Cloned repositories are cached locally to avoid re-cloning
  • Analysis Caching: Dependency analysis results are cached
  • Outdated Package Caching: Results from package registry checks are cached
  • TTL-Based Expiration: Cache expires after a configurable time period

Configuration

Set cache expiry time in hours via environment variable:

# Set in .env file or export
CACHE_EXPIRY_HOURS=24  # Default: 24 hours

Cache Location

Cache is stored at: ~/.cache/ai-dependency-updater/

Cache Management

# View cache statistics
python repository_cache.py stats

# Clean up expired cache entries
python repository_cache.py cleanup

# Clear all cache
python repository_cache.py clear

Cache Benefits

  • ⚑ Faster repeated analyses - No need to re-clone repositories
  • πŸ’° Reduced API calls - Cached package registry lookups
  • 🌐 Works offline - Can analyze previously cached repositories
  • πŸ“Š Smart invalidation - Automatic expiration based on TTL

⚠️ Limitations

  • Some package managers require additional tools (e.g., cargo-outdated for Rust)
  • Large repositories may take time to clone and analyze (first time only, then cached)
  • Some checks require the package manager to be installed locally
  • Network connectivity required for cloning and checking updates (unless using cache)
  • Requires container runtime (Docker/OrbStack/Podman) for GitHub MCP integration
  • Automatically creates PRs on success and Issues when updates fail

πŸ“ Example Scenarios

Scenario 1: Update a Node.js Project

python auto_update_dependencies.py facebook/react

Scenario 2: Update a Python Project

python auto_update_dependencies.py https://github.com/pallets/flask

Scenario 3: Analyze and Update with Auto-Rollback

python dependency_analyzer.py https://github.com/rust-lang/cargo

🀝 Contributing

Contributions are welcome! Areas for improvement:

  • Add more package manager support
  • Implement actual GitHub PR creation
  • Add support for monorepos
  • Improve version parsing and semver handling
  • Add caching for faster repeated analyses
  • Create a web interface

Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - see LICENSE file for details

πŸ“š References

πŸ†˜ Troubleshooting

"Module not found" errors

Make sure all dependencies are installed:

pip install -r requirements.txt

API Key errors

Ensure your Anthropic API key is set:

export ANTHROPIC_API_KEY='your-key-here'

npm/pip not found

Install the required package managers:

Repository cloning fails

  • Check your internet connection
  • Ensure you have git installed
  • Verify the repository URL is correct and public

Built with ❀️ using LangChain and Claude

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors