Compare commits

..

No commits in common. "948ab5a3826dc827c554bb119172eabf07b8c67e" and "d10218f0c8c14e238f43c28e4e0e57693088a9c6" have entirely different histories.

2 changed files with 31 additions and 55 deletions

View File

@ -149,15 +149,12 @@ AIDER_LINT = bash_cmd(
)
LLM_MESSAGE_FORMAT = (
"""{issue}\nDo not wait for explicit approval before working on code changes."""
)
LLM_MESSAGE_FORMAT = """{issue}\nDo not wait for explicit approval before working on code changes."""
# CODE_MODEL = 'ollama/gemma3:4b'
#CODE_MODEL = 'ollama/gemma3:4b'
CODE_MODEL = 'o3'
EVALUATOR_MODEL = 'ollama/gemma3:27b'
def create_aider_command(issue: str) -> list[str]:
l = [
'aider',
@ -238,6 +235,7 @@ def get_diff(cwd: Path, base_branch: str, current_branch: str) -> str:
return result.stdout.strip()
def push_changes(
repository_config: RepositoryConfig,
cwd: Path,
@ -253,9 +251,7 @@ def push_changes(
# Get commit messages for PR description
commit_messages = get_commit_messages(
cwd,
repository_config.base_branch,
branch_name,
cwd, repository_config.base_branch, branch_name,
)
description = f'This pull request resolves #{issue_number}\n\n'
@ -281,9 +277,7 @@ def push_changes(
# Extract PR number and URL if available
return IssueResolution(
True,
str(pr_response.get('number')),
pr_response.get('html_url'),
True, str(pr_response.get('number')), pr_response.get('html_url'),
)
@ -320,7 +314,6 @@ def run_cmd(cmd: list[str], cwd: Path | None = None, check=True) -> bool:
result = subprocess.run(cmd, check=check, cwd=cwd)
return result.returncode == 0
def issue_solution_round(repository_path, issue_content):
# Primary Aider command
aider_command = create_aider_command(issue_content)
@ -340,7 +333,6 @@ def issue_solution_round(repository_path, issue_content):
return True
def run_ollama(cwd: Path, texts: list[str]) -> str:
cmd = ['ollama', 'run', EVALUATOR_MODEL.removeprefix('ollama/')]
print(cmd)
@ -351,12 +343,11 @@ def run_ollama(cwd: Path, texts: list[str]) -> str:
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
)
stdout, stderr = process.communicate('\n'.join(texts))
print(stdout)
return stdout
def parse_yes_no_answer(text: str) -> bool | None:
text = text.lower().strip()
words = text.split('\n \t.,?-')
@ -367,7 +358,6 @@ def parse_yes_no_answer(text: str) -> bool | None:
return False
return None
def run_ollama_and_get_yes_or_no(cwd, initial_texts: list[str]) -> bool:
texts = list(initial_texts)
texts.append('Think through your answer.')
@ -380,27 +370,21 @@ def run_ollama_and_get_yes_or_no(cwd, initial_texts: list[str]) -> bool:
texts.append(response)
texts.append('Please answer either "yes" or "no".')
def verify_solution(repository_path: Path, issue_content: str) -> bool:
summary = run_ollama(
repository_path,
[
'Concisely summarize following changeset',
get_diff(repository_path, 'HEAD', 'main'),
],
)
repository_path,
['Concisely summarize following changeset',
get_diff(repository_path, 'HEAD', 'main')
])
return run_ollama_and_get_yes_or_no(
repository_path,
[
'Does this changeset accomplish the entire task?',
'# Change set',
summary,
'# Issue',
issue_content,
],
)
repository_path,
['Does this changeset accomplish the entire task?',
'# Change set',
summary,
'# Issue',
issue_content,
])
def get_head_commit_hash(repository_path: Path) -> str:
return subprocess.run(
@ -455,27 +439,23 @@ def solve_issue_in_repository(
)
return IssueResolution(False)
# Push changes and create/update the pull request on every iteration
resolution = push_changes(
repository_config,
repository_path,
branch_name,
issue_number,
issue_title,
gitea_client,
)
if not resolution.success:
return resolution
# Verify whether this is a satisfactory solution
if verify_solution(repository_path, issue_content):
return resolution
break
# Push changes
return push_changes(
repository_config,
repository_path,
branch_name,
issue_number,
issue_title,
gitea_client,
)
def solve_issues_in_repository(
repository_config: RepositoryConfig,
client,
seen_issues_db,
repository_config: RepositoryConfig, client, seen_issues_db,
):
"""Process all open issues with the 'aider' label.

View File

@ -23,9 +23,7 @@ class TestHasCommitsOnBranch:
# Verify get_commit_messages was called with correct arguments
mock_get_commit_messages.assert_called_once_with(
self.cwd,
self.base_branch,
self.current_branch,
self.cwd, self.base_branch, self.current_branch,
)
@patch('aider_gitea.get_commit_messages')
@ -41,9 +39,7 @@ class TestHasCommitsOnBranch:
# Verify get_commit_messages was called with correct arguments
mock_get_commit_messages.assert_called_once_with(
self.cwd,
self.base_branch,
self.current_branch,
self.cwd, self.base_branch, self.current_branch,
)
@patch('aider_gitea.get_commit_messages')