使用说明
回购聊天
与GitHub存储库聊天,而无需克隆它们。文件内容根据需要从GitHub API获取,在内存中解码,并且从不写入磁盘。
安装
git clone https://github.com/MertIren/repo-chat
cd repo-chat
pip install -e .
| 变量 | 必填 | 描述 |
|---|---|---|
ANTHROPIC_API_KEY |
仅当使用 claude CLI后端 |
您的Anthropic API密钥 |
GITHUB_TOKEN |
推荐 | 将GitHub的速率限制从每小时60个请求提高到5000个请求;私有仓库需要 |
命令行界面
一个使用两阶段人工智能管道的交互式REPL:模型首先选择要读取的文件,然后用它们的内容进行回答。
默认情况下,它调用 claude CLI(必须安装Claude Code)。要使用其他模型或提供程序,请创建 .repo-chat.toml 工作目录中的文件:
api_key = "your-api-key"
api_url = "https://api.openai.com/v1" # any OpenAI-compatible endpoint
model = "gpt-4o" # optional
适用于ChatGPT(https://api.openai.com/v1)或双子座(https://generativelanguage.googleapis.com/v1beta/openai),或任何其他与OpenAI兼容的API。当文件缺失或为空时 claude CLI会自动使用。
repo-chat https://github.com/owner/repo
repo-chat https://github.com/owner/frontend https://github.com/owner/backend
repo-chat https://github.com/owner/repo/tree/develop
| 命令 | 描述 |
|---|---|
/add <url> |
向会话中添加另一个仓库 |
/clear |
重置对话历史记录和文件缓存 |
/files |
列出当前上下文中的文件 |
/tree [name] |
打印一个或所有存储库的文件树 |
/exit |
退出 |
MCP服务器
将结构化的GitHub浏览工具暴露给Claude Code。与Claude的内置web fetch相比,主要优势在于 私有回购访问 (通过 GITHUB_TOKEN)以及便利工具,如 search_files 和 compare_files.
claude mcp add repo-chat -- repo-chat-mcp
| 工具 | 说明 |
|---|---|
get_repo_info(owner, repo) |
回购元数据,包括默认分支 |
get_file_tree(owner, repo, branch) |
完整的递归文件列表 |
get_file_content(owner, repo, branch, path) |
单个文件内容 |
get_multiple_files(owner, repo, branch, paths) |
并行批量提取最多10个文件 |
search_files(owner, repo, branch, pattern) |
文件树上的全局/子字符串搜索 |
compare_files(files) |
在多个存储库中获取相同的路径 |