{"id":50360821,"url":"https://github.com/codeweiz/pulse-guard","last_synced_at":"2026-05-30T01:21:01.086Z","repository":{"id":294262529,"uuid":"986424090","full_name":"codeweiz/pulse-guard","owner":"codeweiz","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-10T10:16:58.000Z","size":96,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-10T17:34:07.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeweiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-19T15:30:57.000Z","updated_at":"2025-07-10T10:17:02.000Z","dependencies_parsed_at":"2025-06-24T10:24:52.700Z","dependency_job_id":"83100482-a07d-45b7-b4a5-c84e8bcafb80","html_url":"https://github.com/codeweiz/pulse-guard","commit_stats":null,"previous_names":["codeweiz/pulse-guard"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeweiz/pulse-guard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeweiz%2Fpulse-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeweiz%2Fpulse-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeweiz%2Fpulse-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeweiz%2Fpulse-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeweiz","download_url":"https://codeload.github.com/codeweiz/pulse-guard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeweiz%2Fpulse-guard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33677253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-30T01:20:59.609Z","updated_at":"2026-05-30T01:21:01.067Z","avatar_url":"https://github.com/codeweiz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pulse Guard\n\n自动化 PR 代码质量审查工具，基于 LangChain + LangGraph + Deepseek LLM。\n\n## 功能特点\n\n- 监听 GitHub PR Webhook 事件\n- 自动拉取 PR 的 diff、commit 信息\n- 基于 LangChain + Deepseek LLM 进行代码质量分析\n- 自动将分析结果评论到 PR\n- 支持异步后台处理，主线程快速响应\n\n## 技术栈\n\n- **Web 框架**: FastAPI\n- **LLM 集成**: LangChain + LangGraph\n- **异步处理**: Celery + Redis\n- **GitHub 交互**: GitHub REST API\n\n## 项目结构\n\n```\nbackend/\n├── __init__.py\n├── api/                # API 相关模块\n│   ├── __init__.py\n│   ├── routes.py       # API 路由定义\n│   └── webhook.py      # GitHub webhook 处理\n├── llm/                # LLM 相关模块\n│   ├── __init__.py\n│   ├── client.py       # LLM 客户端\n│   └── prompts.py      # 提示模板\n├── agent/              # Agent 相关模块\n│   ├── __init__.py\n│   └── graph.py        # LangGraph 定义\n├── tools/              # 工具函数模块\n│   ├── __init__.py\n│   └── github.py       # GitHub 工具\n├── models/             # 数据模型模块\n│   ├── __init__.py\n│   ├── github.py       # GitHub 数据模型\n│   └── review.py       # 审查结果模型\n├── worker/             # 异步任务模块\n│   ├── __init__.py\n│   ├── celery_app.py   # Celery 配置\n│   └── tasks.py        # 任务定义\n├── config.py           # 配置管理\n└── main.py             # 应用入口\n```\n\n## 安装与配置\n\n### 前置条件\n\n- Python 3.12+\n- Redis\n\n### 安装依赖\n\n使用 uv (推荐):\n\n```bash\n# 安装 uv (如果尚未安装)\ncurl -sSf https://install.uv.dev | sh\n\n# 使用 uv 安装项目依赖\nuv pip install -e .\n\n# 或者安装开发依赖\nuv pip install -e \".[dev]\"\n```\n\n使用传统的 pip:\n\n```bash\npip install -e .\n```\n\n### 配置\n\n1. 复制 `.env.example` 到 `.env` 并填写配置：\n\n```bash\ncp .env.example .env\n```\n\n2. 编辑 `config.toml` 文件配置应用参数。\n\n### 重要配置项\n\n#### 开发模式配置\n\n在开发环境中，您可以启用开发模式，以简化测试过程。在 `config.toml` 中设置：\n\n```toml\n[github]\ndevelopment_mode = true          # 启用开发模式\nverify_webhook_signature = false  # 禁用签名验证\n```\n\n开发模式的特点：\n\n1. **宽松的请求验证**：即使缺少必要的头信息或 JSON 负载无效，也不会拒绝请求\n2. **默认值填充**：自动为缺失的头信息和负载生成默认值\n3. **详细的日志**：提供更多调试信息\n\n在生产环境中，应禁用开发模式并启用签名验证：\n\n```toml\n[github]\ndevelopment_mode = false         # 禁用开发模式\nverify_webhook_signature = true  # 启用签名验证\n```\n\n并确保在 `.env` 文件中设置了 `WEBHOOK_SECRET`。\n\n## 使用方法\n\n### 使用 Makefile\n\n项目提供了 Makefile 来简化常见操作：\n\n```bash\n# 安装依赖\nmake install\n\n# 安装开发依赖\nmake dev\n\n# 运行代码检查\nmake lint\n\n# 格式化代码\nmake format\n\n# 运行测试\nmake test\n\n# 启动 Web 服务\nmake run\n\n# 启动 Celery Worker\nmake worker\n\n# Docker 相关\nmake docker-build\nmake docker-up\nmake docker-down\nmake docker-logs\n\n# 初始化数据库\nmake init-db\n\n# 运行演示\nmake demo\n```\n\n### 手动启动应用\n\n使用 uv (推荐):\n\n```bash\n# 安装依赖\nuv sync\n\n# 启动 Web 服务\nuv run uvicorn backend.main:app --host 0.0.0.0 --port 8000\n\n# 启动 Celery Worker\nuv run python celery_worker.py\n```\n\n### Docker 部署\n\n```bash\n# 构建并启动所有服务\nmake docker-build\nmake docker-up\n\n# 查看服务状态\nmake docker-logs\n\n# 停止服务\nmake docker-down\n```\n\n### 本地开发工作流程\n\n在本地进行开发时，您需要同时运行多个服务并使用 ngrok 创建公网访问点。以下是建议的工作流程：\n\n1. **启动 Redis**（如果尚未运行）：\n\n```bash\nredis-server\n```\n\n2. **启动 Web 服务**（在一个终端窗口）：\n\n```bash\nmake run\n```\n\n3. **启动 Celery Worker**（在另一个终端窗口）：\n\n```bash\nmake worker\n```\n\n4. **启动 ngrok**（在第三个终端窗口）：\n\n```bash\nmake ngrok\n```\n\n5. **配置 GitHub Webhook**：\n   - 使用 ngrok 提供的公网 URL 配置 GitHub webhook\n   - 测试 webhook 触发\n\n### 使用 ngrok 进行本地开发\n\n在本地开发时，您需要使用 ngrok 等工具创建一个公网可访问的 URL，以便 GitHub 可以将 webhook 请求发送到您的本地服务器。\n\n1. 安装 ngrok（如果尚未安装）：\n\n```bash\n# 使用 Homebrew 安装（macOS）\nbrew install ngrok\n\n# 或者从官网下载：https://ngrok.com/download\n```\n\n2. 启动 ngrok：\n\n```bash\n# 将本地的 8000 端口映射到公网\nngrok http 8000\n```\n\n3. ngrok 启动后，它会显示一个公网 URL（如 `https://1234abcd.ngrok.io`），记下这个 URL。\n\n### 配置 GitHub Webhook\n\n1. 在 GitHub 仓库设置中添加 Webhook\n2. 设置 Payload URL 为 `https://your-ngrok-url/api/webhook/github`（如果使用 ngrok）或 `http://your-server/api/webhook/github`（生产环境）\n3. 选择 Content type 为 `application/json`\n4. 设置 Secret（与 `.env` 中的 `WEBHOOK_SECRET` 一致）\n5. 选择 \"Let me select individual events\" 并勾选 \"Pull requests\"\n\n### 手动触发审查\n\n可以通过 API 手动触发代码审查：\n\n```bash\ncurl -X POST \"http://localhost:8000/api/review?repo=owner/repo\u0026pr_number=123\"\n```\n\n## 扩展性\n\nPulse Guard 设计具有高度可扩展性：\n\n- **LLM 提供者**: 通过配置文件轻松切换不同的 LLM\n- **代码审查类型**: 可以添加新的审查类型\n- **Git 平台**: 架构支持扩展到其他 Git 平台\n\n## 许可证\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeweiz%2Fpulse-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeweiz%2Fpulse-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeweiz%2Fpulse-guard/lists"}