Skip to content

farhanmir/CodeSonor

Repository files navigation

CodeSonor 🔍

AI-powered GitHub repository analyzer with multi-LLM support - Choose from 8 different AI providers!

PyPI version Python Version License: MIT Downloads

Analyze any GitHub repository with AI-powered insights. Get language statistics, code summaries, and repository metrics in seconds.

🚀 Quick Start

pip install codesonor
codesonor setup  # Interactive configuration wizard
codesonor analyze https://github.com/pallets/flask

✨ Features

  • 🤖 Multi-LLM Support - Choose from Gemini, OpenAI, Claude, Mistral, or Groq
  • 🔧 Interactive Setup - One-time configuration wizard saves your preferences
  • 📊 Language Analysis - Distribution breakdown across 20+ programming languages
  • 🧠 AI Code Summaries - AI-generated insights for key files
  • 📈 Repository Stats - Stars, forks, contributors, file counts
  • Fast Analysis - Smart filtering and caching
  • 🎨 Beautiful Output - Rich terminal formatting with tables and colors
  • 💾 Export Options - JSON output for integration

🤖 Supported AI Providers

Provider Free Tier Speed Quality Best For
Gemini ✅ Yes Fast Good Beginners
OpenAI ❌ Paid Medium Excellent Production
Claude ❌ Paid Fast Excellent Long code
Mistral ❌ Paid Fast Good Europe
Groq ✅ Yes Ultra-fast Good Speed
OpenRouter 🌐 💳 Pay-per-use Fast Excellent 100+ models
xAI Grok ❌ Paid Fast Excellent Latest tech
Ollama 🆓 ✅ FREE Medium Good Privacy/Local

⭐ Default provider | ⚡ Fastest inference | 🌐 Access to 100+ models | 🆓 Runs locally, no API key needed

📦 Installation

Basic Installation (includes Gemini)

pip install codesonor

With Specific Provider

pip install codesonor[openai]      # For OpenAI GPT
pip install codesonor[anthropic]   # For Claude
pip install codesonor[mistral]     # For Mistral
pip install codesonor[groq]        # For Groq
# Note: OpenRouter, xAI, and Ollama use OpenAI-compatible APIs (included by default)
pip install codesonor[all-llm]     # All providers

🔧 Configuration

Interactive Setup (Recommended)

codesonor setup

This wizard will:

  1. Let you choose your preferred AI provider
  2. Guide you to get the API key
  3. Optionally select a specific model
  4. Save everything to ~/.codesonor/config.json

Manual Configuration

Edit ~/.codesonor/config.json:

{
  "github_token": "ghp_your_token_here",
  "llm_provider": "openai",
  "llm_api_key": "sk-your-key",
  "llm_model": "gpt-4"
}

Environment Variables

# GitHub token (optional but recommended)
export GITHUB_TOKEN="ghp_your_token"

# LLM provider API keys (choose one or more)
export GEMINI_API_KEY="your_key"
export OPENAI_API_KEY="sk-your_key"
export ANTHROPIC_API_KEY="sk-ant-your_key"
export MISTRAL_API_KEY="your_key"
export GROQ_API_KEY="gsk_your_key"
export OPENROUTER_API_KEY="sk-or-your_key"
export XAI_API_KEY="xai-your_key"
# Ollama runs locally, no API key needed!

📖 Usage

Basic Analysis

codesonor analyze https://github.com/torvalds/linux

Use Specific Provider

# OpenAI GPT-4
codesonor analyze URL --llm-provider openai --llm-model gpt-4

# Anthropic Claude
codesonor analyze URL --llm-provider anthropic

# Groq (fastest)
codesonor analyze URL --llm-provider groq

Advanced Options

# Skip AI analysis (stats only, faster)
codesonor analyze URL --no-ai

# Limit files analyzed
codesonor analyze URL --max-files 100

# Export as JSON
codesonor analyze URL --json-output results.json

# Quick summary without AI
codesonor summary https://github.com/django/django

Check Configuration

codesonor config

Output:

📋 CodeSonor Configuration

┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Setting       ┃ Status        ┃ Source     ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ GitHub Token  │ ✅ Configured │ config     │
│ LLM Provider  │ Openai        │ config     │
│ LLM Model     │               │ gpt-4      │
│ LLM API Key   │ ✅ Configured │ config     │
└───────────────┴───────────────┴────────────┘

🎯 Example Output

╭─────────────────────────────────────────────────╮
│  Repository: flask by pallets                   │
╰─────────────────────────────────────────────────╯

Stars: ⭐ 70,501  Forks: 🔱 16,551
Primary Language: Python
Total Files: 218

Language Distribution:
┏━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Language  ┃ Percentage ┃ Bar                     ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Python    │    95.80%  │ ███████████████████████ │
│ HTML      │     1.74%  │ █                       │
│ YAML      │     1.15%  │ █                       │
└───────────┴────────────┴─────────────────────────┘

🤖 AI-Powered Code Analysis
File 1: src/flask/app.py
Flask application core implementation. Defines the Flask class which
serves as the central object for WSGI applications...

🔑 Getting API Keys

🛠️ Tech Stack

  • Python 3.9+
  • Click - CLI framework
  • Rich - Terminal formatting
  • Requests - HTTP library
  • Multiple LLM SDKs - OpenAI, Anthropic, Groq, Mistral, Google Generative AI

📚 Documentation

🤝 Contributing

Contributions are welcome! Please check out our Contributing Guide.

📄 License

MIT License - see LICENSE file for details.

🌟 Star History

If you find CodeSonor useful, please consider giving it a star! ⭐

📧 Support

🚀 What's New in v0.4.1

  • OpenRouter Support - Access to 100+ AI models with a single API key
  • 🤖 xAI Grok - Latest AI from xAI
  • 🆓 Ollama Integration - Run AI models locally for FREE (no API key needed!)
  • 🧹 Code Quality - Enhanced metadata and package information
  • 8 LLM Providers - More choice than ever before!

See V0.4.1_UPDATE.md for complete details.

Made by Farhan Mir

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors