github_analyzer 1.0.0 copy "github_analyzer: ^1.0.0" to clipboard
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 #

How to get a token:

  1. Go to GitHub Settings β†’ Tokens
  2. Generate fine-grained token (recommended)
  3. Set Contents: Read-only permission
  4. 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 토큰 λ°œκΈ‰ (μ„ νƒμ‚¬ν•­μ΄μ§€λ§Œ ꢌμž₯) #

토큰 λ°œκΈ‰ 방법:

  1. GitHub Settings β†’ Tokens λ°©λ¬Έ
  2. Fine-grained 토큰 생성 (ꢌμž₯)
  3. Contents: Read-only κΆŒν•œ μ„€μ •
  4. 토큰 볡사

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


2
likes
150
points
840
downloads

Publisher

unverified uploader

Weekly Downloads

Analyze GitHub repositories and generate AI context for LLMs with cross-platform support

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

archive, crypto, dio, freezed_annotation, get_it, glob, json_annotation, logging, path, universal_io

More

Packages that depend on github_analyzer