中文 | English
CodePilot 是一个基于 Spring Boot 3 的 Issue-to-Patch / Issue-to-PR Agent 原型项目,面向 GitHub 仓库问题分析、代码检索、LLM 分析与 patch 生成场景。
当前仓库包含:
- Spring Boot 3 后端
frontend/下的 React + Vite 前端控制台
- 用户注册、登录、JWT 鉴权
- 项目仓库记录管理
- Agent 任务创建、查询、异步运行
- JGit 仓库拉取
- Tree-sitter 多语言解析与文本兜底抽取
code_file/code_symbol持久化- Lucene 本地索引构建与多语言代码搜索
- CodeRanker 结果重排
- LLM 分析与 patch 生成抽象
- patch_record 落库与查询
- Redis 任务运行锁
- Spring Async 后台执行
- SSE 任务事件订阅
后端现在采用单层主包结构,不再在每个主层级下继续按业务二次分包,主要依靠类名区分职责:
src/main/java/com/codepliot
├── client
├── config
├── controller
├── entity
├── exception
├── handler
├── model
├── repository
├── service
├── policy
├── policy
└── utils
说明:
controller:HTTP 接口entity:数据库实体exception:业务异常定义handler:全局异常处理、安全过滤器/处理器model:DTO、VO、上下文、返回模型、枚举repository:Mapper / Repositoryservice:业务服务、执行编排、索引与工具实现client:外部客户端抽象或实现utils:工具类
主配置文件:
启动前请准备:
- MySQL 数据库
codepilot - Redis 实例
- 可写的工作目录
codepilot.workspace.root - 合法的 JWT 密钥
- 可用的 LLM 配置
推荐方式:
mvn package -DskipTests
java -jar target/codepilot-0.0.1-SNAPSHOT.jar默认地址:
http://localhost:8080
说明:
- 如果
mvn clean失败,通常是本地有进程占用了target/下的文件;关闭相关 Java 进程后再执行即可。
cd frontend
npm install
npm run dev默认地址:
http://localhost:5173
cd frontend
npm install
npm run build:static然后启动后端即可通过 http://localhost:8080 访问前端。
任务实时事件订阅接口:
GET /api/tasks/{taskId}/events
当前前端会将 SSE 收敛为三个阶段:
- 开始
- 执行中
- 完成 / 失败
当前 MVP 使用:
- Spring Async
- Redis 运行锁
而不是 MQ,原因是:
- 当前仍是单体应用
- 任务依赖本地 workspace 与本地 Lucene 索引
- Spring Async + Redis 已能满足当前需求
如果后续演进为多实例或独立 worker 架构,再升级到 RabbitMQ / Redis Stream 更合适。
CodePilot is a Spring Boot 3 based Issue-to-Patch / Issue-to-PR prototype for GitHub repository analysis, code retrieval, LLM-based issue analysis, and patch generation.
This repository contains:
- a Spring Boot backend
- a React + Vite frontend console under
frontend/
- user registration, login, and JWT auth
- project repository record management
- agent task creation, querying, and async execution
- JGit repository sync
- Tree-sitter multi-language parsing with text fallback
- persistence of
code_file/code_symbol - local Lucene index build and multi-language code search
- CodeRanker reranking
- LLM analysis and patch generation abstraction
- patch record persistence, safety review, and manual confirmation
- Redis-backed task run lock
- Spring Async background execution
- SSE task event subscription
The backend now uses a flat top-level layer layout. There are no additional business subpackages under each main layer; class names are used to convey the domain meaning:
src/main/java/com/codepliot
├── client
├── config
├── controller
├── entity
├── exception
├── handler
├── model
├── repository
├── service
└── utils
Main config file:
Prepare before startup:
- MySQL database
codepilot - Redis instance
- writable
codepilot.workspace.root - valid JWT secret
- working LLM configuration
Recommended:
mvn package -DskipTests
java -jar target/codepilot-0.0.1-SNAPSHOT.jarBackend address:
http://localhost:8080
Note:
- If
mvn cleanfails, a local process is usually holding files undertarget/.
cd frontend
npm install
npm run devFrontend dev address:
http://localhost:5173
cd frontend
npm install
npm run build:staticThen start the backend and open http://localhost:8080.
Task event subscription endpoint:
GET /api/tasks/{taskId}/events
The current frontend condenses SSE into three stages:
- started
- running
- completed / failed
- After patch generation, tasks now enter
WAITING_CONFIRMinstead of going directly toCOMPLETED - The backend runs a rule-based patch safety check before manual confirmation
- Manual confirmation endpoint:
POST /api/tasks/{taskId}/confirm
- This MVP still does not auto-apply patches or create PRs
The current MVP uses:
- Spring Async
- Redis task run locks
instead of MQ, because:
- the app is still a monolith
- task execution depends on local workspace files and local Lucene indexes
- Spring Async + Redis is sufficient for the current stage
RabbitMQ or Redis Stream would be a more natural next step for multi-instance or worker-based deployment later.