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:
meeks
2026-07-19 17:49:33 +02:00
committed by Michael
parent ee01487ce3
commit dfdd8c0931
11 changed files with 300 additions and 107 deletions
+9 -4
View File
@@ -37,7 +37,8 @@ def test_get_file_content_failure() -> None:
file_tools: FileTools = FileTools(mock_client)
res: str = file_tools.get_file_content("owner", "repo", "path/to/file")
assert "Error getting file content: API Error" in res
assert "Could not retrieve file" in res
assert "path/to/file" in res
def test_get_file_content_with_ref_string_success() -> None:
@@ -73,7 +74,8 @@ def test_get_file_content_with_ref_failure() -> None:
res: str = file_tools.get_file_content_with_ref(
"owner", "repo", "path/to/file", "main"
)
assert "Error getting file content: API Error" in res
assert "Could not retrieve file" in res
assert "path/to/file" in res
def test_commit_file_success() -> None:
@@ -98,7 +100,8 @@ def test_commit_file_failure() -> None:
res: str = file_tools.commit_file(
"owner", "repo", "path/to/file", "msg", "content", "branch"
)
assert "Error committing file: API Error" in res
assert "Could not commit file" in res
assert "path/to/file" in res
def test_update_file_success() -> None:
@@ -123,11 +126,13 @@ def test_update_file_failure() -> None:
res: str = file_tools.update_file(
"owner", "repo", "path/to/file", "msg", "content", "branch"
)
assert "Error updating file: API Error" in res
assert "Could not update file" in res
assert "path/to/file" in res
def test_get_file_content_uses_local_file_when_available(tmp_path: str) -> None:
import os
mock_client = _create_mock_client()
repo_dir = tmp_path / "owner" / "repo"
+13 -7
View File
@@ -56,7 +56,8 @@ def test_close_issue_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.close_issue("owner", "repo", 1)
assert "Error closing issue: API Error" in res
assert "Could not close issue" in res
assert "owner/repo" in res
def test_get_issue_comments_success() -> None:
@@ -77,7 +78,8 @@ def test_get_issue_comments_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.get_issue_comments("owner", "repo", 1)
assert "Error getting issue comments: API Error" in res
assert "Could not retrieve comments" in res
assert "owner/repo" in res
def test_list_assigned_issues_success() -> None:
@@ -120,7 +122,7 @@ def test_list_issues_empty() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.list_issues("owner", "repo")
assert res == "No issues in owner/repo."
assert res == "No open issues in owner/repo."
def test_list_issues_failure() -> None:
@@ -129,7 +131,8 @@ def test_list_issues_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.list_issues("owner", "repo")
assert "Error listing issues: API Error" in res
assert "Could not list issues" in res
assert "owner/repo" in res
def test_create_issue_success() -> None:
@@ -153,7 +156,8 @@ def test_create_issue_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.create_issue("owner", "repo", "Title", "Body")
assert "Error creating issue: API Error" in res
assert "Could not create issue" in res
assert "Title" in res
def test_add_label_to_issue_success() -> None:
@@ -171,7 +175,8 @@ def test_add_label_to_issue_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.add_label_to_issue("owner", "repo", 1, "bug")
assert "Error adding label to issue #1: API Error" in res
assert "Could not add label" in res
assert "bug" in res
def test_add_comment_to_issue_success() -> None:
@@ -189,4 +194,5 @@ def test_add_comment_to_issue_failure() -> None:
issue_tools: IssueTools = IssueTools(mock_client)
res: str = issue_tools.add_comment_to_issue("owner", "repo", 1, "body")
assert "Error adding comment to issue #1: API Error" in res
assert "Could not add comment" in res
assert "owner/repo" in res
+17 -9
View File
@@ -58,7 +58,8 @@ def test_close_pull_request_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.close_pull_request("owner", "repo", 1)
assert "Error closing pull request: API Error" in res
assert "Could not close PR" in res
assert "owner/repo" in res
def test_get_pull_request_comments_success() -> None:
@@ -79,7 +80,8 @@ def test_get_pull_request_comments_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.get_pull_request_comments("owner", "repo", 1)
assert "Error getting PR comments: API Error" in res
assert "Could not retrieve comments" in res
assert "owner/repo" in res
def test_list_assigned_pull_requests_success() -> None:
@@ -124,7 +126,7 @@ def test_list_pull_requests_empty() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.list_pull_requests("owner", "repo")
assert res == "No PRs in owner/repo."
assert res == "No open PRs in owner/repo."
def test_list_pull_requests_failure() -> None:
@@ -133,7 +135,8 @@ def test_list_pull_requests_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.list_pull_requests("owner", "repo")
assert "Error listing PRs: API Error" in res
assert "Could not list PRs" in res
assert "owner/repo" in res
def test_create_pull_request_success() -> None:
@@ -179,7 +182,8 @@ def test_add_label_to_pr_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.add_label_to_pr("owner", "repo", 1, "bug")
assert "Error adding label to PR #1: API Error" in res
assert "Could not add label" in res
assert "bug" in res
def test_get_pull_request_diff_success() -> None:
@@ -197,7 +201,8 @@ def test_get_pull_request_diff_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.get_pull_request_diff("owner", "repo", 1)
assert "Error getting PR diff: API Error" in res
assert "Could not retrieve diff" in res
assert "owner/repo" in res
def test_get_pull_request_patch_success() -> None:
@@ -215,7 +220,8 @@ def test_get_pull_request_patch_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.get_pull_request_patch("owner", "repo", 1)
assert "Error getting PR patch: API Error" in res
assert "Could not retrieve patch" in res
assert "owner/repo" in res
def test_approve_pull_request_success() -> None:
@@ -233,7 +239,8 @@ def test_approve_pull_request_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.approve_pull_request("owner", "repo", 1, "good")
assert "Error approving PR: API Error" in res
assert "Could not approve PR" in res
assert "owner/repo" in res
def test_request_changes_success() -> None:
@@ -251,4 +258,5 @@ def test_request_changes_failure() -> None:
pr_tools: PRTools = PRTools(mock_client)
res: str = pr_tools.request_changes("owner", "repo", 1, "bad")
assert "Error requesting changes: API Error" in res
assert "Could not request changes" in res
assert "owner/repo" in res