github_analyzer 1.0.0
github_analyzer: ^1.0.0 copied to clipboard
Analyze GitHub repositories and generate AI context for LLMs with cross-platform support
README Tabs (English / νκ΅μ΄) #
πΊπΈ English Version
GitHub Analyzer #
Powerful GitHub Repository Analysis Tool for AI/LLM
A pure Dart package that analyzes GitHub repositories and automatically generates markdown documentation optimized for AI and LLM contexts.
β¨ Key Features #
- π Fast & Efficient - Optimized with isolate-based parallel processing
- π¦ Dual Mode - Supports both local directories and remote GitHub repositories
- π― LLM Optimized - Generates compact context for AI models
- π Incremental Updates - Smart caching for fast re-analysis
- π Cross-Platform - Works on web, desktop, and mobile
- π Private Repositories - Access private repos with GitHub tokens
- β‘ Cache Control - Explicitly enable/disable caching
- π Explicit Token Management - Direct token passing for better security
π¦ Installation #
Add to your pubspec.yaml:
dependencies:
github_analyzer: ^1.0.0
Install:
dart pub get
or
dart pub add github_analyzer
π Quick Start #
1. Get GitHub Token (Optional but Recommended) #
How to get a token:
- Go to GitHub Settings β Tokens
- Generate fine-grained token (recommended)
- Set Contents: Read-only permission
- Copy the token
2. Basic Usage (Public Repository) #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final result = await analyzeQuick(
'https://github.com/flutter/flutter',
);
print('Files: ${result.statistics.totalFiles}');
print('Lines: ${result.statistics.totalLines}');
print('Language: ${result.metadata.language}');
}
3. Private Repository Analysis #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final result = await analyzeQuick(
'https://github.com/your/private-repo',
githubToken: 'ghp_your_token_here',
);
print('Files: ${result.statistics.totalFiles}');
}
4. Generate Markdown for LLM #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final outputPath = await analyzeForLLM(
'https://github.com/your/repo',
githubToken: 'ghp_your_token_here',
outputDir: './analysis',
maxFiles: 200,
);
print('Generated: $outputPath');
}
5. Advanced Usage #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final config = await GithubAnalyzerConfig.create(
githubToken: 'ghp_your_token_here',
excludePatterns: ['test/', 'docs/'],
maxFileSize: 1024 * 1024,
enableCache: true,
);
final analyzer = await GithubAnalyzer.create(config: config);
final result = await analyzer.analyzeRemote(
repositoryUrl: 'https://github.com/your/repo',
useCache: false,
);
final contextService = ContextService();
final outputPath = await contextService.generate(
result,
outputDir: './output',
config: MarkdownConfig.compact,
);
print('Generated: $outputPath');
await analyzer.dispose();
}
βοΈ Configuration Options #
Quick Analysis (Fast) #
final config = await GithubAnalyzerConfig.quick(
githubToken: 'your_token',
);
- β‘ Fast speed
- π Max 100 files
- π« Cache disabled
- π« Isolate disabled
LLM Optimized (Balanced) #
final config = await GithubAnalyzerConfig.forLLM(
githubToken: 'your_token',
maxFiles: 200,
);
- βοΈ Balanced performance
- π Custom file count
- β Cache enabled
- β Isolate enabled
- π§ͺ Test files excluded
Full Analysis (Comprehensive) #
final config = await GithubAnalyzerConfig.create(
githubToken: 'your_token',
enableCache: true,
enableIsolatePool: true,
maxConcurrentRequests: 10,
);
- π Detailed analysis
- βΎοΈ Unlimited files
- β‘ Maximum concurrency
- πΎ Optimized caching
π Private Repository Access #
Use in Code #
final result = await analyzeQuick(
'https://github.com/user/private-repo',
githubToken: 'ghp_your_token_here',
);
final config = await GithubAnalyzerConfig.create(
githubToken: 'ghp_your_token_here',
);
final analyzer = await GithubAnalyzer.create(config: config);
Secure Token Management #
import 'dart:io';
void main() async {
final token = Platform.environment['GITHUB_TOKEN'];
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: token,
);
}
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
Future<void> analyze() async {
final storage = FlutterSecureStorage();
final token = await storage.read(key: 'github_token');
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: token,
);
}
π οΈ Convenience Functions #
final result = await analyzeQuick('https://github.com/user/repo');
final result = await analyzeQuick(
'https://github.com/user/private-repo',
githubToken: 'your_token',
);
final outputPath = await analyzeForLLM(
'https://github.com/user/repo',
githubToken: 'your_token',
outputDir: './output',
maxFiles: 100,
);
final result = await analyze(
'https://github.com/user/repo',
config: await GithubAnalyzerConfig.create(
githubToken: 'your_token',
),
verbose: true,
useCache: false,
);
π Troubleshooting #
403 Forbidden Error #
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: 'ghp_your_token_here',
);
404 Not Found Error #
Verify repository URL is correct and add GitHub token for private repos.
Cache Not Respecting useCache: false #
final result = await analyzer.analyze(
'https://github.com/user/repo',
useCache: false,
);
π Examples #
Check out more examples in the example/ directory.
π License #
MIT License
π°π· νκ΅μ΄ λ²μ
GitHub Analyzer #
AI/LLMμ μν κ°λ ₯ν GitHub μ μ₯μ λΆμ λꡬ
GitHub μ μ₯μλ₯Ό λΆμνκ³ AI λ° LLM 컨ν μ€νΈμ μ΅μ νλ λ§ν¬λ€μ΄ λ¬Έμλ₯Ό μλ μμ±νλ μμ Dart ν¨ν€μ§μ λλ€.
β¨ μ£Όμ κΈ°λ₯ #
- π λΉ λ₯΄κ³ ν¨μ¨μ - Isolate κΈ°λ° λ³λ ¬ μ²λ¦¬λ‘ μ΅μ ν
- π¦ μ΄μ€ λͺ¨λ - λ‘컬 λλ ν 리 λ° μ격 GitHub μ μ₯μ μ§μ
- π― LLM μ΅μ ν - AI λͺ¨λΈμ μν κ°κ²°ν 컨ν μ€νΈ μμ±
- π μ¦λΆ μ λ°μ΄νΈ - λΉ λ₯Έ μ¬λΆμμ μν μ€λ§νΈ μΊμ±
- π ν¬λ‘μ€ νλ«νΌ - μΉ, λ°μ€ν¬ν±, λͺ¨λ°μΌμμ μλ
- π λΉκ³΅κ° μ μ₯μ - GitHub ν ν°μΌλ‘ λΉκ³΅κ° μ μ₯μ μ κ·Ό
- β‘ μΊμ μ μ΄ - μΊμ±μ λͺ μμ μΌλ‘ νμ±ν/λΉνμ±ν
- π λͺ μμ ν ν° κ΄λ¦¬ - 보μ κ°νλ₯Ό μν μ§μ ν ν° μ λ¬
π¦ μ€μΉ #
pubspec.yamlμ μΆκ°:
dependencies:
github_analyzer: ^1.0.0
μ€μΉ:
dart pub get
λλ
dart pub add github_analyzer
π λΉ λ₯Έ μμ #
1. GitHub ν ν° λ°κΈ (μ νμ¬νμ΄μ§λ§ κΆμ₯) #
ν ν° λ°κΈ λ°©λ²:
- GitHub Settings β Tokens λ°©λ¬Έ
- Fine-grained ν ν° μμ± (κΆμ₯)
- Contents: Read-only κΆν μ€μ
- ν ν° λ³΅μ¬
2. κΈ°λ³Έ μ¬μ©λ² (κ³΅κ° μ μ₯μ) #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final result = await analyzeQuick(
'https://github.com/flutter/flutter',
);
print('νμΌ: ${result.statistics.totalFiles}');
print('λΌμΈ: ${result.statistics.totalLines}');
print('μΈμ΄: ${result.metadata.language}');
}
3. λΉκ³΅κ° μ μ₯μ λΆμ #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final result = await analyzeQuick(
'https://github.com/your/private-repo',
githubToken: 'ghp_your_token_here',
);
print('νμΌ: ${result.statistics.totalFiles}');
}
4. LLMμ© λ§ν¬λ€μ΄ μμ± #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final outputPath = await analyzeForLLM(
'https://github.com/your/repo',
githubToken: 'ghp_your_token_here',
outputDir: './analysis',
maxFiles: 200,
);
print('μμ±λ¨: $outputPath');
}
5. κ³ κΈ μ¬μ©λ² #
import 'package:github_analyzer/github_analyzer.dart';
void main() async {
final config = await GithubAnalyzerConfig.create(
githubToken: 'ghp_your_token_here',
excludePatterns: ['test/', 'docs/'],
maxFileSize: 1024 * 1024,
enableCache: true,
);
final analyzer = await GithubAnalyzer.create(config: config);
final result = await analyzer.analyzeRemote(
repositoryUrl: 'https://github.com/your/repo',
useCache: false,
);
final contextService = ContextService();
final outputPath = await contextService.generate(
result,
outputDir: './output',
config: MarkdownConfig.compact,
);
print('μμ±λ¨: $outputPath');
await analyzer.dispose();
}
βοΈ μ€μ μ΅μ #
λΉ λ₯Έ λΆμ (κ³ μ) #
final config = await GithubAnalyzerConfig.quick(
githubToken: 'your_token',
);
- β‘ λΉ λ₯Έ μλ
- π μ΅λ 100κ° νμΌ
- π« μΊμ λΉνμ±ν
- π« Isolate λΉνμ±ν
LLM μ΅μ ν (κ· ν) #
final config = await GithubAnalyzerConfig.forLLM(
githubToken: 'your_token',
maxFiles: 200,
);
- βοΈ κ· νμ‘ν μ±λ₯
- π μ¬μ©μ μ μ νμΌ μ
- β μΊμ νμ±ν
- β Isolate νμ±ν
- π§ͺ ν μ€νΈ νμΌ μ μΈ
μ 체 λΆμ (μ’ ν©) #
final config = await GithubAnalyzerConfig.create(
githubToken: 'your_token',
enableCache: true,
enableIsolatePool: true,
maxConcurrentRequests: 10,
);
- π μμΈ λΆμ
- βΎοΈ 무μ ν νμΌ
- β‘ μ΅λ λμμ±
- πΎ μ΅μ νλ μΊμ±
π λΉκ³΅κ° μ μ₯μ μ κ·Ό #
μ½λμμ μ¬μ© #
final result = await analyzeQuick(
'https://github.com/user/private-repo',
githubToken: 'ghp_your_token_here',
);
final config = await GithubAnalyzerConfig.create(
githubToken: 'ghp_your_token_here',
);
final analyzer = await GithubAnalyzer.create(config: config);
ν ν° μμ κ΄λ¦¬ #
import 'dart:io';
void main() async {
final token = Platform.environment['GITHUB_TOKEN'];
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: token,
);
}
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
Future<void> analyze() async {
final storage = FlutterSecureStorage();
final token = await storage.read(key: 'github_token');
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: token,
);
}
π οΈ νΈμ ν¨μ #
final result = await analyzeQuick('https://github.com/user/repo');
final result = await analyzeQuick(
'https://github.com/user/private-repo',
githubToken: 'your_token',
);
final outputPath = await analyzeForLLM(
'https://github.com/user/repo',
githubToken: 'your_token',
outputDir: './output',
maxFiles: 100,
);
final result = await analyze(
'https://github.com/user/repo',
config: await GithubAnalyzerConfig.create(
githubToken: 'your_token',
),
verbose: true,
useCache: false,
);
π λ¬Έμ ν΄κ²° #
403 Forbidden μ€λ₯ #
final result = await analyzeQuick(
'https://github.com/user/repo',
githubToken: 'ghp_your_token_here',
);
404 Not Found μ€λ₯ #
μ μ₯μ URLμ΄ μ ννμ§ νμΈνκ³ λΉκ³΅κ° μ μ₯μμ λν΄ GitHub ν ν°μ μΆκ°νμΈμ.
useCache: falseλ₯Ό 무μνλ μΊμ #
final result = await analyzer.analyze(
'https://github.com/user/repo',
useCache: false,
);
π μμ #
example/ λλ ν 리μμ λ λ§μ μμ λ₯Ό νμΈνμΈμ.
π λΌμ΄μ μ€ #
MIT License