fix: improve prompts, error messages, and workspace concurrency
- Externalize coordinator, notification, and planning prompts to separate files - Add workspace mutex for concurrent file operations - Improve error messages across file_tools, issue_tools, and pr_tools - Add logging to tool modules for better debugging - Update tests to match new error message strings
This commit is contained in:
@@ -27,7 +27,14 @@ class IssueTools:
|
||||
self._client.issues.close_issue(owner, repo, issue_number)
|
||||
return f"Issue #{issue_number} closed successfully."
|
||||
except Exception as e:
|
||||
return f"Error closing issue: {str(e)}"
|
||||
logger.error(
|
||||
f"Failed to close issue #{issue_number} in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not close issue #{issue_number} in {owner}/{repo}. "
|
||||
f"Check permissions or if the issue is already closed. Details: {e}"
|
||||
)
|
||||
|
||||
def get_issue_comments(
|
||||
self,
|
||||
@@ -58,7 +65,14 @@ class IssueTools:
|
||||
)
|
||||
return result
|
||||
except Exception as e:
|
||||
return f"Error getting issue comments: {str(e)}"
|
||||
logger.error(
|
||||
f"Failed to get comments for issue #{issue_number} in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not retrieve comments for issue #{issue_number} in {owner}/{repo}. "
|
||||
f"Verify the issue exists and you have access. Details: {e}"
|
||||
)
|
||||
|
||||
def list_assigned_issues(self) -> list[dict[str, Any]]:
|
||||
try:
|
||||
@@ -86,11 +100,18 @@ class IssueTools:
|
||||
try:
|
||||
issues = self._client.issues.list_repo_issues(owner, repo, state)
|
||||
if not issues:
|
||||
return f"No issues in {owner}/{repo}."
|
||||
return f"No {state} issues in {owner}/{repo}."
|
||||
summary = [f"#{issue.number}: {issue.title}" for issue in issues]
|
||||
return "\n".join(summary)
|
||||
except Exception as e:
|
||||
return f"Error listing issues: {str(e)}"
|
||||
logger.error(
|
||||
f"Failed to list {state} issues in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not list issues for {owner}/{repo}. "
|
||||
f"Verify the repository exists and you have access. Details: {e}"
|
||||
)
|
||||
|
||||
def create_issue(
|
||||
self,
|
||||
@@ -107,7 +128,14 @@ class IssueTools:
|
||||
)
|
||||
return f"Issue #{issue.number} created successfully in {owner}/{repo}."
|
||||
except Exception as e:
|
||||
return f"Error creating issue: {str(e)}"
|
||||
logger.error(
|
||||
f"Failed to create issue '{title}' in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not create issue '{title}' in {owner}/{repo}. "
|
||||
f"Check repository permissions and label/assignee names. Details: {e}"
|
||||
)
|
||||
|
||||
def add_label_to_issue(
|
||||
self, owner: str, repo: str, issue_number: int, label: str
|
||||
@@ -116,7 +144,14 @@ class IssueTools:
|
||||
self._client.issues.add_label(owner, repo, issue_number, label)
|
||||
return f"Label '{label}' added to issue #{issue_number}."
|
||||
except Exception as e:
|
||||
return f"Error adding label to issue #{issue_number}: {e}"
|
||||
logger.error(
|
||||
f"Failed to add label '{label}' to issue #{issue_number} in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not add label '{label}' to issue #{issue_number} in {owner}/{repo}. "
|
||||
f"Verify the label exists in the repository. Details: {e}"
|
||||
)
|
||||
|
||||
def add_comment_to_issue(
|
||||
self, owner: str, repo: str, issue_number: int, body: str
|
||||
@@ -125,4 +160,11 @@ class IssueTools:
|
||||
self._client.issues.add_comment(owner, repo, issue_number, body)
|
||||
return f"Comment added to issue #{issue_number}."
|
||||
except Exception as e:
|
||||
return f"Error adding comment to issue #{issue_number}: {e}"
|
||||
logger.error(
|
||||
f"Failed to add comment to issue #{issue_number} in {owner}/{repo}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
return (
|
||||
f"Error: Could not add comment to issue #{issue_number} in {owner}/{repo}. "
|
||||
f"Verify the issue exists and you have write access. Details: {e}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user