feat: Add referenced file footers to AI comments and correct Gitea PR 'synchronize' action to 'synchronized'.

This commit is contained in:
vinland100 2026-01-04 15:07:37 +08:00
parent d01d3850df
commit 7fa9bb5c26
3 changed files with 10 additions and 7 deletions

View File

@ -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:

View File

@ -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 差异

View File

@ -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)