update
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 32s

This commit is contained in:
2025-12-28 14:10:04 +00:00
parent c17a61b27a
commit 69d9963597
17 changed files with 627 additions and 444 deletions

View File

@@ -262,9 +262,7 @@ class IssueAgent(BaseAgent):
if labels_to_add:
try:
self.gitea.add_issue_labels(owner, repo, issue_index, labels_to_add)
return [
name for name, id in label_map.items() if id in labels_to_add
]
return [name for name, id in label_map.items() if id in labels_to_add]
except Exception as e:
self.logger.warning(f"Failed to add labels: {e}")
@@ -336,6 +334,8 @@ class IssueAgent(BaseAgent):
return self._command_explain(title, body)
elif command == "suggest":
return self._command_suggest(title, body)
elif command == "triage":
return self._command_triage(context, issue)
return f"{self.AI_DISCLAIMER}\n\nSorry, I don't understand the command `{command}`."
@@ -390,3 +390,33 @@ Be practical and concise."""
return f"{self.AI_DISCLAIMER}\n\n**Suggestions:**\n{response.content}"
except Exception as e:
return f"{self.AI_DISCLAIMER}\n\nSorry, I was unable to generate suggestions. Error: {e}"
def _command_triage(self, context: AgentContext, issue: dict) -> str:
"""Perform full triage analysis on the issue."""
title = issue.get("title", "")
body = issue.get("body", "")
author = issue.get("user", {}).get("login", "unknown")
existing_labels = [l.get("name", "") for l in issue.get("labels", [])]
issue_index = issue.get("number")
try:
# Perform triage analysis
triage = self._triage_issue(title, body, author, existing_labels)
# Apply labels if enabled
agent_config = self.config.get("agents", {}).get("issue", {})
labels_applied = []
if agent_config.get("auto_label", True):
labels_applied = self._apply_labels(
context.owner, context.repo, issue_index, triage
)
# Generate response
response = self._generate_triage_comment(triage, issue)
if labels_applied:
response += f"\n\n**Labels Applied:** {', '.join(labels_applied)}"
return response
except Exception as e:
return f"{self.AI_DISCLAIMER}\n\nSorry, I was unable to triage this issue. Error: {e}"