diff --git a/backend/app/api/v1/endpoints/webhooks.py b/backend/app/api/v1/endpoints/webhooks.py index 3159497..ad831b8 100644 --- a/backend/app/api/v1/endpoints/webhooks.py +++ b/backend/app/api/v1/endpoints/webhooks.py @@ -22,7 +22,7 @@ async def process_gitea_event(event_type: str, payload: dict): ci_service = CIService(db) if event_type == "pull_request": action = payload.get("action") - if action in ["opened", "synchronize", "reopened"]: + if action in ["opened", "synchronized", "reopened"]: logger.info(f"Starting background PR processing for action: {action}") await ci_service.handle_pr_event(payload) else: diff --git a/backend/app/core/ci_prompts.py b/backend/app/core/ci_prompts.py index 8257a09..323d463 100644 --- a/backend/app/core/ci_prompts.py +++ b/backend/app/core/ci_prompts.py @@ -60,10 +60,10 @@ PR_REVIEW_TASK = """ PR_REVIEW_OUTPUT_FORMAT = """ 仅输出 Markdown 格式的响应,格式如下: -## 🔍 DeepAudit 评审摘要 +## 🔍 AI Review 摘要 <简要总结变更内容及整体风险等级> -## 🛡️ 发现评审意见 +## 🛡️ 评审意见 ### [严重程度: 高/中/低] <意见标题> - **文件**: `<文件路径>` - **意见**: <描述具体问题或改进建议> @@ -101,7 +101,7 @@ PR_SYNC_TASK = """ # ----------------------------------------------------------------------------- CHAT_SYSTEM_PROMPT = """ -你是 DeepAudit Bot,一个集成在 CI/CD 工作流中的得力 AI 助手。 +你是 AI Code Review Bot,一个集成在 CI/CD 工作流中的得力 AI 助手。 你正在 PR 评论区与开发者交流。 用户提到了你 (@ai-bot) 以询问问题或请求澄清。 你可以通过 RAG (检索增强生成) 访问代码库的相关片段,并能看到当前的 PR 差异。 diff --git a/backend/app/services/ci_service.py b/backend/app/services/ci_service.py index ee33c68..fbc2e33 100644 --- a/backend/app/services/ci_service.py +++ b/backend/app/services/ci_service.py @@ -95,7 +95,7 @@ class CIService: repo_context = "\n".join([r.to_context_string() for r in context_results]) # 5. 生成评审 - if action == "synchronize": + if action == "synchronized": # 增量同步模式:获取全部对话历史 history = await self._get_conversation_history(repo, pr_number) @@ -125,7 +125,10 @@ class CIService: review_body = response["content"] # 6. Post Comment - await self._post_gitea_comment(repo, pr_number, review_body) + # 附加上下文信息页脚 + footer_parts = [f"`{r.file_path}`" for r in context_results] + footer = "\n\n---\n*本次评审参考了以下文件: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*" + await self._post_gitea_comment(repo, pr_number, review_body + footer) # 7. Save Record review_record = PRReview( @@ -262,7 +265,7 @@ class CIService: # 7. 回复 # 附加上下文信息页脚 footer_parts = [f"`{r.file_path}`" for r in context_results] - footer = "\n\n---\n*本次回答参考了以下文件上下文: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*" + footer = "\n\n---\n*本次回答参考了以下文件: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*" await self._post_gitea_comment(repo, issue.get("number"), answer + footer) # 6. Record (Optional, maybe just log)