diff --git a/openhands/resolver/README.md b/openhands/resolver/README.md index 01455e72aa..349bf23a6b 100644 --- a/openhands/resolver/README.md +++ b/openhands/resolver/README.md @@ -121,13 +121,13 @@ Note: OpenHands works best with powerful models like Anthropic's Claude or OpenA The resolver can automatically attempt to fix a single issue in your repository using the following command: ```bash -python -m openhands.resolver.resolve_issue --repo [OWNER]/[REPO] --issue-number [NUMBER] +python -m openhands.resolver.resolve_issue --selected-repo [OWNER]/[REPO] --issue-number [NUMBER] ``` For instance, if you want to resolve issue #100 in this repo, you would run: ```bash -python -m openhands.resolver.resolve_issue --repo all-hands-ai/openhands --issue-number 100 +python -m openhands.resolver.resolve_issue --selected-repo all-hands-ai/openhands --issue-number 100 ``` The output will be written to the `output/` directory. @@ -135,19 +135,19 @@ The output will be written to the `output/` directory. If you've installed the package from source using poetry, you can use: ```bash -poetry run python openhands/resolver/resolve_issue.py --repo all-hands-ai/openhands --issue-number 100 +poetry run python openhands/resolver/resolve_issue.py --selected-repo all-hands-ai/openhands --issue-number 100 ``` For resolving multiple issues at once (e.g., in a batch process), you can use the `resolve_all_issues` command: ```bash -python -m openhands.resolver.resolve_all_issues --repo [OWNER]/[REPO] --issue-numbers [NUMBERS] +python -m openhands.resolver.resolve_all_issues --selected-repo [OWNER]/[REPO] --issue-numbers [NUMBERS] ``` For example: ```bash -python -m openhands.resolver.resolve_all_issues --repo all-hands-ai/openhands --issue-numbers 100,101,102 +python -m openhands.resolver.resolve_all_issues --selected-repo all-hands-ai/openhands --issue-numbers 100,101,102 ``` ## Responding to PR Comments diff --git a/openhands/resolver/resolve_all_issues.py b/openhands/resolver/resolve_all_issues.py index 7696c06d2a..3640e4b8d7 100644 --- a/openhands/resolver/resolve_all_issues.py +++ b/openhands/resolver/resolve_all_issues.py @@ -234,7 +234,7 @@ def main() -> None: description='Resolve multiple issues from Github or Gitlab.' ) parser.add_argument( - '--repo', + '--selected-repo', type=str, required=True, help='Github or Gitlab repository to resolve issues in form of `owner/repo`.', @@ -333,7 +333,7 @@ def main() -> None: f'ghcr.io/all-hands-ai/runtime:{openhands.__version__}-nikolaik' ) - owner, repo = my_args.repo.split('/') + owner, repo = my_args.selected_repo.split('/') token = my_args.token or os.getenv('GITHUB_TOKEN') or os.getenv('GITLAB_TOKEN') username = my_args.username if my_args.username else os.getenv('GIT_USERNAME') if not username: @@ -342,7 +342,7 @@ def main() -> None: if not token: raise ValueError('Token is required.') - platform = identify_token(token) + platform = identify_token(token, my_args.selected_repo) if platform == Platform.INVALID: raise ValueError('Token is invalid.') diff --git a/openhands/resolver/resolve_issue.py b/openhands/resolver/resolve_issue.py index 8443b361fd..51887723ee 100644 --- a/openhands/resolver/resolve_issue.py +++ b/openhands/resolver/resolve_issue.py @@ -539,7 +539,7 @@ def main() -> None: parser = argparse.ArgumentParser(description='Resolve a single issue.') parser.add_argument( - '--repo', + '--selected-repo', type=str, required=True, help='repository to resolve issues in form of `owner/repo`.', @@ -638,9 +638,9 @@ def main() -> None: f'ghcr.io/all-hands-ai/runtime:{openhands.__version__}-nikolaik' ) - parts = my_args.repo.rsplit('/', 1) + parts = my_args.selected_repo.rsplit('/', 1) if len(parts) < 2: - raise ValueError('Invalid repo name') + raise ValueError('Invalid repository format. Expected owner/repo') owner, repo = parts token = my_args.token or os.getenv('GITHUB_TOKEN') or os.getenv('GITLAB_TOKEN') @@ -651,7 +651,7 @@ def main() -> None: if not token: raise ValueError('Token is required.') - platform = identify_token(token, repo) + platform = identify_token(token, my_args.selected_repo) if platform == Platform.INVALID: raise ValueError('Token is invalid.') diff --git a/openhands/resolver/utils.py b/openhands/resolver/utils.py index 65129e12c0..9cfff94eec 100644 --- a/openhands/resolver/utils.py +++ b/openhands/resolver/utils.py @@ -22,13 +22,13 @@ class Platform(Enum): GITLAB = 2 -def identify_token(token: str, repo: str | None = None) -> Platform: +def identify_token(token: str, selected_repo: str | None = None) -> Platform: """ Identifies whether a token belongs to GitHub or GitLab. Parameters: token (str): The personal access token to check. - repo (str): Repository in format "owner/repo" for GitHub Actions token validation. + selected_repo (str): Repository in format "owner/repo" for GitHub Actions token validation. Returns: Platform: "GitHub" if the token is valid for GitHub, @@ -36,8 +36,8 @@ def identify_token(token: str, repo: str | None = None) -> Platform: "Invalid" if the token is not recognized by either. """ # Try GitHub Actions token format (Bearer) with repo endpoint if repo is provided - if repo: - github_repo_url = f'https://api.github.com/repos/{repo}' + if selected_repo: + github_repo_url = f'https://api.github.com/repos/{selected_repo}' github_bearer_headers = { 'Authorization': f'Bearer {token}', 'Accept': 'application/vnd.github+json', @@ -50,7 +50,7 @@ def identify_token(token: str, repo: str | None = None) -> Platform: if github_repo_response.status_code == 200: return Platform.GITHUB except requests.RequestException as e: - print(f'Error connecting to GitHub API (repo check): {e}') + print(f'Error connecting to GitHub API (selected_repo check): {e}') # Try GitHub PAT format (token) github_url = 'https://api.github.com/user'