High-performance async GitHub repository analyzer with AI-optimized code extraction and smart .env file support
Project description
๐ py-github-analyzer
High-performance async GitHub repository analyzer with AI-optimized code extraction and smart .env file support
โจ Features
๐ Advanced Authentication
- โ
Fine-grained Token Support: Latest GitHub token standard with
Bearerauthentication - โ
Classic Token Support: Traditional
ghp_tokens withtokenauthentication - ๐ Auto Token Detection: Automatically detects token type and uses appropriate authentication
- ๐ Multi-source Token Loading: Environment variables, .env files, CLI parameters
- ๐ Private Repository Access: Full access to private repositories with proper permissions
โก High Performance
- ๐ฏ ZIP-first Strategy: Optimal download method with intelligent API fallback
- ๐ Smart Rate Limit Management: Adaptive strategies for different token types
- ๐ Pure Async Architecture: Built with modern async/await patterns for maximum performance
- ๐ Intelligent Fallback: Graceful degradation when ZIP access fails
๐ Smart Analysis
- ๐ Automatic Language Detection: Accurate detection and dependency mapping
- ๐ Intelligent File Filtering: Skip binaries, focus on source code with priority scoring
- ๐ฆ Multiple Output Formats: JSON metadata and structured code extraction
- ๐ฏ Framework Detection: Identifies popular frameworks and patterns
๐ Cross-Platform
- ๐ป Windows, macOS, and Linux: Full compatibility across all platforms
- ๐ก๏ธ Smart Error Handling: Comprehensive error messages and recovery strategies
- ๐ Smart .env Support: Automatically finds and loads tokens from .env files
๐ฆ Installation
From PyPI (Recommended)
pip install py-github-analyzer
From Source
Bash
git clone [https://github.com/cruxhan/py-github-analyzer.git](https://github.com/cruxhan/py-github-analyzer.git)
cd py-github-analyzer
pip install -e .
๐ GitHub Token Setup (Recommended)
Supported Token Types
py-github-analyzer supports all GitHub token types with automatic detection:
๐ Fine-grained Personal Access Tokens (Latest)
Prefix: github_pat_
Authentication: Bearer header
Permissions: Repository-specific granular access
Security: โ
Enhanced security with minimal required permissions
Performance: โ ๏ธ API-only access for private repos (ZIP may fail)
Setup: GitHub Settings โ Developer settings โ Personal access tokens โ Fine-grained tokens
๐ Classic Personal Access Tokens (Traditional)
Prefix: ghp_
Authentication: token header
Permissions: Broad scope-based access
Security: โ ๏ธ Wide access permissions
Performance: โ
Full ZIP and API access
Setup: GitHub Settings โ Developer settings โ Personal access tokens โ Tokens (classic)
Creating Tokens
For Fine-grained Tokens (Recommended for Security):
Visit GitHub Settings โ Personal Access Tokens โ Fine-grained tokens
Select Repository access: Choose specific repositories or all repositories
Set Repository permissions:
Contents: Read (required for file access)
Actions: Read (required for ZIP downloads)
Metadata: Read (required for repository info)
Copy the token (starts with github_pat_)
For Classic Tokens (Faster for Bulk Analysis):
Visit GitHub Settings โ Personal Access Tokens โ Tokens (classic)
Click Generate new token (classic)
Select repo scope for private repository access
Copy the token (starts with ghp_)
Setting Up Your Token
Option 1: Environment Variable (Recommended)
Bash
# For Linux/macOS
export GITHUB_TOKEN=your_token_here
# For Windows (Command Prompt)
set GITHUB_TOKEN=your_token_here
Option 2: .env file in your project directory
Bash
echo "GITHUB_TOKEN=your_token_here" > .env
Option 3: CLI parameter
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --github-token your_token_here
๐ Usage Examples
Basic Usage
Analyze a public repository
Bash
py-github-analyzer [https://github.com/octocat/Hello-World](https://github.com/octocat/Hello-World)
Analyze with verbose output
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --verbose
Specify output directory and format
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --output-dir ./results --output-format json
Advanced Options
Force specific analysis method
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --method api
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --method zip
Multiple output formats
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --output-format both
Dry run (test without processing)
Bash
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --dry-run
๐ Output Format
JSON Structure
JSON
{
"metadata": {
"repo": "owner/repository-name",
"desc": "Repository description",
"lang": ["Primary", "Secondary", "Languages"],
"size": {
"repo_size": "288KB",
"source_size": "294.2KB",
"display_size": "288KB"
},
"files": 117,
"main": ["main.py", "app.py", "index.js"],
"deps": ["dependency1", "dependency2"],
"created": 1634567890,
"version": "1.0.0"
},
"files": [
{
"path": "src/main.py",
"content": "file content here",
"size": 1234,
"lines": 45,
"language": "Python",
"priority": 950
}
]
}
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
Bash
git clone [https://github.com/cruxhan/py-github-analyzer.git](https://github.com/cruxhan/py-github-analyzer.git)
cd py-github-analyzer
# Create virtual environment
python -m venv venv
# On Windows: venv\Scripts\activate
# On Linux/macOS: source venv/bin/activate
source venv/bin/activate
# Install development dependencies
pip install -e .[dev]
# Run tests
poe test
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Made with โค๏ธ for developers who need fast, reliable GitHub repository analysis
py-github-analyzer v1.0.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_github_analyzer-1.0.1.tar.gz
(58.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_github_analyzer-1.0.1.tar.gz.
File metadata
- Download URL: py_github_analyzer-1.0.1.tar.gz
- Upload date:
- Size: 58.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae58f9ff7b5b0c68a65c16d257bd274ff4786d4f5875c27af314ac1fc565709c
|
|
| MD5 |
3fb7ed6bcb5aa6bf9a18b42b4062fe30
|
|
| BLAKE2b-256 |
5663b20c034d2d19d97168abf62dddbc90992399085f19587ee3522e923ad37b
|
File details
Details for the file py_github_analyzer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: py_github_analyzer-1.0.1-py3-none-any.whl
- Upload date:
- Size: 60.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f65303a0d7f710d5e56cbc0bb661252c9910a0afae6121205bc35b39227548cf
|
|
| MD5 |
ff3009129bcbff4d6e79ed96f047d84d
|
|
| BLAKE2b-256 |
33321bc677d40ff1090dabe90276654cc2573af76618821ff7d6cf63f24330cd
|