coding-jhj/RepoPilot

GitHub: coding-jhj/RepoPilot

一个免费优先的 GitHub 仓库分析 Agent,在无需付费 LLM 或数据库的前提下克隆、索引代码并生成带证据的静态分析结果和补丁草案。

Stars: 0 | Forks: 0

# RepoPilot [English README](README.en.md) 在线演示: [https://jeonghwanju-repopilot.hf.space](https://jeonghwanju-repopilot.hf.space/) RepoPilot 是一个免费的 Web 演示项目,它可以获取公开的 GitHub 存储库,对代码进行索引,并展示包含文件/行数依据的分析结果和补丁草案。它无需 OpenAI、Claude、付费数据库或付费 vector DB 即可运行。 如果您想详细了解项目的结构和代码,可以查看在线渲染的 [RepoPilot 代码导读](https://coding-jhj.github.io/RepoPilot/)。 ![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=flat-square&logo=python&logoColor=white) ![FastAPI](https://img.shields.io/badge/FastAPI-Backend-009688?style=flat-square&logo=fastapi&logoColor=white) ![Next.js](https://img.shields.io/badge/Next.js-Static_UI-000000?style=flat-square&logo=nextdotjs&logoColor=white) ![Hugging Face](https://img.shields.io/badge/Deploy-Hugging%20Face%20Spaces-FFD21E?style=flat-square) ![Free](https://img.shields.io/badge/Cost-Free--first-1c6dd0?style=flat-square) ## 当前已实现的功能 - 输入公开的 GitHub 存储库 URL - clone 存储库并创建临时 workspace - 对 Python、JavaScript、TypeScript、Markdown 文件进行索引 - 基于Python AST 提取 class/function/import - 基于 JS/TS/TSX tree-sitter 进行精准解析(class、method、interface、type、enum、arrow-function、import) - 基于 local retrieval 搜索相关代码 chunk - 显示 agent timeline - 显示包含文件/行数依据的 finding - 执行免费的静态分析 rule - hardcoded secret 候选 - bare `except:` - 使用 `eval()` - 基于选定的 evidence path 生成 patch draft - 验证 patch 是否在已批准的文件范围内 - 创建真实的 GitHub Pull Request(opt-in:提供 token 时会自动创建分支 -> 提交文件 -> 开启 PR;无 token 时则使用 mock) - 由 FastAPI 一同 serving Next.js static export - 在 Hugging Face Spaces CPU Basic 上免费部署 ## 暂不支持的功能 - 基于 LLM 的深度真实 bug 推理 - 自动应用 unified diff(实际的 PR 会接收明确的文件内容) - 对整个大型 repo 进行分析 - 永久存储或保存用户各自的 history 本项目并非一个“完美的 Devin 克隆版”,而是一个 **MVP**,旨在展示**在零成本的免费环境下,究竟能将实战型的 Agent 架构实现到什么程度**。 ## 使用流程 ``` GitHub URL 입력 -> repo clone -> 파일 인덱싱 -> 코드 chunk 검색 -> agent workflow 실행 -> evidence 기반 finding 표시 -> patch draft 생성 -> scope validation ``` ## 架构 ``` flowchart TD A["GitHub URL"] --> B["RepoService"] B --> C["Temporary Workspace"] C --> D["IndexingService"] D --> E["CodeParser"] D --> F["CodeChunker"] F --> G["InMemoryRetriever"] G --> H["RepoPilotAgent"] H --> I["StaticRuleAnalyzer"] H --> J["Evidence-backed Findings"] J --> K["PatchService"] K --> L["Diff Review UI"] ``` ## Agent Workflow ``` Planner -> RepoReader -> CodeSearcher -> ArchitectureAnalyzer -> BugDetector -> TestWriter -> PatchWriter -> Reviewer ``` 核心原则: ## 技术栈 | 领域 | 技术 | | --- | --- | | Backend | FastAPI, Pydantic | | Frontend | Next.js static export, React, TypeScript | | Deployment | Hugging Face Spaces Docker | | Code Analysis | Python AST, JS/TS/TSX tree-sitter (regex fallback) | | Retrieval | In-memory chunk search | | Static Rules | hardcoded secret, bare except, eval 检测 | | GitHub | 创建真实的 PR (opt-in token, httpx REST) | | LLM | 默认不使用 | | Tests | pytest, Next.js build | ## 免费部署结构 ``` Hugging Face Spaces CPU Basic -> Dockerfile -> Next.js static export -> FastAPI static file serving -> local static-analysis agent ``` 为了保持免费,我们未使用以下内容: - OpenAI API - Claude API - paid inference API - Qdrant Cloud - hosted database - GPU instance 在 Space 环境中,我们对 repo/file 的大小和 clone timeout 进行了限制。 ``` REPOPILOT_MAX_FILES_INDEXED=120 REPOPILOT_MAX_FILE_BYTES=120000 REPOPILOT_CLONE_TIMEOUT_SECONDS=45 ``` ## 本地运行 Backend: ``` cd apps/api python -m pip install -e .[dev] uvicorn app.main:app --reload ``` Frontend: ``` cd apps/web npm install npm run dev ``` Docker: ``` docker build -t repopilot . docker run --rm -p 7860:7860 repopilot ``` ## 测试 Backend: ``` cd apps/api python -m pytest tests ``` Frontend: ``` cd apps/web npm install npm run build ``` 当前验证状态: - backend tests: `23 passed` (Python 3.13) - 包含 tree-sitter JS/TS 解析及真实 PR 流程的回归测试 - 通过 Next.js static export build - 确认 Hugging Face Space `/health` 响应 - 确认 Hugging Face Space 网页返回 HTTP `200` ## 主要文件 ``` apps/api/app/main.py # FastAPI app + static frontend serving apps/api/app/services/repo_service.py # GitHub URL validation, clone, workspace path apps/api/app/services/indexing_service.py# file walking, parsing, chunk indexing apps/api/app/code/parser.py # Python ast + JS/TS dispatch (regex fallback) apps/api/app/code/treesitter_parser.py # tree-sitter JS/TS/TSX symbol & import 추출 apps/api/app/code/rules.py # free static-analysis rules apps/api/app/agents/graph.py # agent node workflow runner apps/api/app/services/patch_service.py # patch draft + scope validation apps/api/app/services/github_service.py # PR entry (mock vs real, 토큰 분기) apps/api/app/services/github_pr_service.py # 실제 GitHub REST PR 흐름 apps/web/app/page.tsx # main demo UI Dockerfile # Hugging Face Spaces deployment image ``` ## 后续改进计划 - 扩展静态分析 rule set - 基于 dependency graph 的风险检测 - 提升 patch template 的质量 - 添加小型 demo repo 的 benchmark - 通过自动应用 unified diff 来实现 PR 文件生成的自动化 - 在前端接入 PR token 输入 UI ## 局限性 在免费部署环境中,CPU、磁盘、网络和执行时间都存在限制。因此,RepoPilot 主要针对小型公开 repo 的演示进行了优化。当前的 finding 并非基于 LLM 推理,而是基于 deterministic static rule。
标签:AV绕过, FastAPI, GitHub自动化, 代码审查, 代码索引, 代码补丁, 安全规则引擎, 请求拦截, 运行时操纵, 逆向工具, 错误基检测, 静态代码分析