Gitingest

Gitingestのフロントページスクリーンショット

PyPI Python Versions
CI Ruff OpenSSF Scorecard
License Downloads GitHub Stars Discord
Trendshift

GitリポジトリをLLM向けのプロンプトに適したテキスト形式に変換します。

GitHubのURLでhubingestに置き換えるだけで、対応するダイジェストにアクセスできます。

gitingest.com · Chrome拡張機能 · Firefoxアドオン

Deutsch | Español | Français | 日本語 | 한국어 | Português | Русский | 中文

🚀 特徴

  • 簡単なコードコンテキスト: GitリポジトリURLまたはディレクトリからテキストダイジェストを取得
  • スマートフォーマット: LLMプロンプト向けに最適化された出力形式
  • 統計情報:
    • ファイルとディレクトリ構造
    • 抽出サイズ
    • トークン数
  • CLIツール: シェルコマンドとして実行可能
  • Pythonパッケージ: コード内でインポートして使用可能

📚 要件

📦 インストール

GitingestはPyPIで利用可能です。 pipを使用してインストールできます:

pip install gitingest

ただし、pipxを使用してインストールするのが良いでしょう。 pipxはお好みのパッケージマネージャーでインストールできます。

brew install pipx
apt install pipx
scoop install pipx
...

初めてpipxを使用する場合は、以下を実行してください:

pipx ensurepath
# install gitingest
pipx install gitingest

🧩 ブラウザ拡張機能の使用方法

Available in the Chrome Web Store Get The Add-on for Firefox Get from the Edge Add-ons

この拡張機能はオープンソースで、lcandy2/gitingest-extension で公開されています。

リポジトリでは問題報告や機能リクエストを歓迎しています。

💡 コマンドラインの使用方法

gitingest コマンドラインツールを使用すると、コードベースを分析し、その内容をテキストダンプとして作成できます。

# Basic usage (writes to digest.txt by default)
gitingest /path/to/directory

# From URL
gitingest https://github.com/cyclotruc/gitingest

# or from specific subdirectory
gitingest https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils

プライベートリポジトリの場合は、--token/-t オプションを使用してください。

# Get your token from https://github.com/settings/personal-access-tokens
gitingest https://github.com/username/private-repo --token github_pat_...

# Or set it as an environment variable
export GITHUB_TOKEN=github_pat_...
gitingest https://github.com/username/private-repo

# Include repository submodules
gitingest https://github.com/username/repo-with-submodules --include-submodules

デフォルトでは、.gitignore にリストされているファイルはスキップされます。ダイジェストにこれらのファイルを含める必要がある場合は、--include-gitignored を使用してください。

デフォルトでは、ダイジェストは現在の作業ディレクトリのテキストファイル (digest.txt) に書き込まれます。出力をカスタマイズするには2つの方法があります:

  • --output/-o <filename> を使用して特定のファイルに書き込みます。
  • --output/-o - を使用して直接 STDOUT に出力します(他のツールにパイプする場合に便利です)。

詳細なオプションと使用方法については以下を参照してください:

gitingest --help

🐍 Pythonパッケージの使用方法

# Synchronous usage
from gitingest import ingest

summary, tree, content = ingest("path/to/directory")

# or from URL
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")

# or from a specific subdirectory
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils")

プライベートリポジトリの場合は、トークンを渡すことができます:

# Using token parameter
summary, tree, content = ingest("https://github.com/username/private-repo", token="github_pat_...")

# Or set it as an environment variable
import os
os.environ["GITHUB_TOKEN"] = "github_pat_..."
summary, tree, content = ingest("https://github.com/username/private-repo")

# Include repository submodules
summary, tree, content = ingest("https://github.com/username/repo-with-submodules", include_submodules=True)

デフォルトではファイルは書き込まれませんが、output 引数で有効にできます。

# Asynchronous usage
from gitingest import ingest_async
import asyncio

result = asyncio.run(ingest_async("path/to/directory"))

Jupyter notebookでの使用方法

from gitingest import ingest_async

# Use await directly in Jupyter
summary, tree, content = await ingest_async("path/to/directory")

これは、Jupyter notebookがデフォルトで非同期であるためです。

🐳 セルフホスト

  1. イメージをビルド:

    docker build -t gitingest .
    
  2. コンテナを実行:

    docker run -d --name gitingest -p 8000:8000 gitingest
    

アプリケーションは http://localhost:8000 で利用可能になります。

ドメインでホストする場合、環境変数 ALLOWED_HOSTS を通じて許可するホスト名を指定できます。

   # Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1".
   ALLOWED_HOSTS="example.com, localhost, 127.0.0.1"

🤝 コントリビューション

技術的でない貢献方法

  • Issueの作成: バグを見つけたり新機能のアイデアがある場合は、GitHubでissueを作成してください。これによりリクエストの追跡と優先順位付けが容易になります。
  • 宣伝: Gitingestが気に入ったら、友人や同僚、SNSで共有してください。コミュニティの成長とGitingestの改善に繋がります。
  • Gitingestを使用: 実際の使用から得られるフィードバックが最良です!問題が発生したり改善アイデアがあれば、GitHubでissueを作成するか、Discordでお知らせください。

技術的な貢献方法

Gitingestは初めてのコントリビューターにも優しいPythonとHTMLのシンプルなコードベースを目指しています。コード作業中に助けが必要な場合は、Discordでご連絡ください。プルリクエストの作成方法の詳細はCONTRIBUTING.mdをご覧ください。

🛠️ 技術スタック

JavaScript/FileSystemNodeパッケージをお探しですか?

NPM代替品📦 Repomixをご覧ください: https://github.com/yamadashy/repomix

🚀 プロジェクト成長

Star History Chart