将任意 Git 代码库转换为适合大语言模型(LLM)提示的文本摘要。
您也可以将 GitHub URL 中的 hub
替换为 ingest
来获取对应摘要。
gitingest.com · Chrome扩展 · Firefox插件
Deutsch | Español | Français | 日本語 | 한국어 | Português | Русский | 中文
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
扩展开源地址: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
默认会跳过 .gitignore
中列出的文件。如需包含这些文件,请使用 --include-gitignored
参数。
默认情况下,摘要会输出到当前工作目录的 digest.txt
文件。可通过两种方式自定义输出:
--output/-o <文件名>
指定输出文件--output/-o -
直接输出到标准输出(便于管道操作)查看完整选项与使用说明:
gitingest --help
# 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")
默认不会写入文件,可通过 output
参数启用。
# Asynchronous usage
from gitingest import ingest_async
import asyncio
result = asyncio.run(ingest_async("path/to/directory"))
from gitingest import ingest_async
# Use await directly in Jupyter
summary, tree, content = await ingest_async("path/to/directory")
这是因为 Jupyter notebook 默认采用异步模式。
构建镜像:
docker build -t gitingest .
运行容器:
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"
Gitingest 对首次贡献者友好,采用简洁的 Python 和 HTML 代码架构。开发过程中如需帮助,请通过 Discord 联系我们。提交 PR 的详细指南请参阅 CONTRIBUTING.md。
推荐 NPM 替代方案 📦 Repomix:https://github.com/yamadashy/repomix