Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(resolver): implement gitlab resolver #6458

Merged
merged 59 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a5380e0
[Refactor]: Resolver: way to support more than github
josx Nov 28, 2024
f515893
branch_exists and get_branch_name functions refactored
Orianamartina Dec 27, 2024
f6ade51
refactor(resolver) add pull url and authorize url functions
cuococarlos Dec 27, 2024
a9470d4
Linted code
Orianamartina Dec 27, 2024
338a60e
removed unnecesary parameter from functions
Orianamartina Dec 27, 2024
7ca2c8d
add parameters type
cuococarlos Dec 27, 2024
3090347
Merge pull request #3 from Cambalab/create-authorize-and-pull-urls-fu…
cuococarlos Dec 27, 2024
aca0879
Update: added types to parameters
Orianamartina Dec 27, 2024
c036c5e
Merge branch 'resolver_abs' into resolver_abs_ori
cuococarlos Dec 27, 2024
590d1ad
Merge pull request #1 from Cambalab/resolver_abs_ori
cuococarlos Dec 27, 2024
5f57655
get_branch_url (#2)
juanmanueldaza Dec 27, 2024
2b0463d
[refactor] resolver: create pull request function
Orianamartina Dec 27, 2024
73a4e78
linted code
Orianamartina Dec 27, 2024
41989de
[refactor]: default branch name refactored into IssueHandler
Orianamartina Dec 27, 2024
48a8548
[refactor] remove unnecesary params from handler functions
Orianamartina Dec 27, 2024
330dae3
get_graphql_url() abstrated to github.py
juanmanueldaza Dec 27, 2024
12fa77f
reply_to_comment() abstracted to github.py
juanmanueldaza Dec 27, 2024
76551b0
fix linter issues
cuococarlos Jan 7, 2025
9a16910
Fix the conflit of main
wtiger9218 Feb 8, 2025
a313253
Fix the conflit of resolver_abs
wtiger9218 Jan 13, 2025
ce07281
Implement the issue resovler and create merge request for gitlab
wtiger9218 Jan 14, 2025
0078832
Implement the merge request resolver for gitlab
wtiger9218 Jan 15, 2025
0057f32
Implement webhoook API for gitlab
wtiger9218 Jan 16, 2025
c7ca863
Fix the group issue of gitlab
wtiger9218 Jan 17, 2025
aefd0c8
Fix the issue that didn't find user
wtiger9218 Jan 18, 2025
b8bd48c
Implement the multiple instance for runtime container
wtiger9218 Jan 18, 2025
e229538
Gitlab Updates
symbaventures Jan 19, 2025
e9b35a7
Edit apply.py
symbaventures Jan 20, 2025
8ebff20
Fix the permission issue
wtiger9218 Jan 20, 2025
5fe20e8
Update the git action for gitlab
wtiger9218 Jan 20, 2025
5c6fb76
Update the comment
wtiger9218 Jan 20, 2025
2c55534
Update the unit tests for github
wtiger9218 Jan 20, 2025
ff92f64
Update the unit testing path for github
wtiger9218 Jan 20, 2025
bf8ed9c
Implement unit testings for gitlab
wtiger9218 Jan 22, 2025
5a03803
Fix the unit testing issues
wtiger9218 Jan 25, 2025
2a97377
Update GIT_TOKEN to GITHUB_TOKEN and GITLAB_TOKEN
wtiger9218 Jan 31, 2025
1a77a22
Remove hooks APIs
wtiger9218 Jan 31, 2025
2159292
Update the funtion names in gitlab route
wtiger9218 Jan 31, 2025
7d4421a
Update the document
wtiger9218 Jan 31, 2025
0e5c275
Comment openhand route for gitlab
wtiger9218 Feb 5, 2025
83893f3
Fix the rebase issue
wtiger9218 Feb 8, 2025
29c33c0
Remove gitlab routes
wtiger9218 Feb 10, 2025
9834863
Remove sudo in locally for gitlab
wtiger9218 Feb 10, 2025
efd2807
Remove gitlab.md of microagents
wtiger9218 Feb 10, 2025
2c69056
Update microagents/tasks/address_pr_comments.md
malhotra5 Feb 10, 2025
c95d2e7
added a comment (no code change)
enyst Feb 10, 2025
6c4ebf5
Update github workflow
wtiger9218 Feb 11, 2025
20fe792
Apply suggestions from code review
malhotra5 Feb 11, 2025
31ac799
Update openhands/resolver/resolve_issue.py
malhotra5 Feb 11, 2025
dc1f1b4
Update some comments and log messages
wtiger9218 Feb 11, 2025
2b4bf27
Update the local_runtime_url & user_id for gitlab
wtiger9218 Feb 11, 2025
d989f73
Add README for gitlab
wtiger9218 Feb 11, 2025
d750c18
Update readme files
wtiger9218 Feb 11, 2025
3dd2c19
Update some suggestions
wtiger9218 Feb 11, 2025
3459f80
Create the subfolder for the interface definition, github and gitlab …
wtiger9218 Feb 12, 2025
795f74b
Implement ServiceContext class
wtiger9218 Feb 12, 2025
1335fe2
Update the send_pull_request.py
wtiger9218 Feb 13, 2025
9cac804
Update openhands/resolver/interfaces/issue_definitions.py
malhotra5 Feb 13, 2025
448178b
Fix python lint issue
wtiger9218 Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/openhands-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ jobs:
- name: Attempt to resolve issue
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }}
GITHUB_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }}
GIT_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }}
LLM_MODEL: ${{ secrets.LLM_MODEL || inputs.LLM_MODEL }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
Expand Down Expand Up @@ -267,7 +267,7 @@ jobs:
if: always() # Create PR or branch even if the previous steps fail
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }}
GITHUB_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }}
GIT_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }}
LLM_MODEL: ${{ secrets.LLM_MODEL || inputs.LLM_MODEL }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
Expand Down
3 changes: 3 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default defineConfig(({ mode }) => {
// rewriteWsOrigin: true,
},
},
watch: {
ignored: ['**/node_modules/**', '**/.git/**'],
},
},
ssr: {
noExternal: ["react-syntax-highlighter"],
Expand Down
6 changes: 3 additions & 3 deletions openhands/resolver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pip install openhands-ai
# GitHub credentials

export GITHUB_TOKEN="your-github-token"
export GITHUB_USERNAME="your-github-username" # Optional, defaults to token owner
export GIT_USERNAME="your-github-username" # Optional, defaults to token owner

# LLM configuration

Expand Down Expand Up @@ -169,13 +169,13 @@ There are three ways you can upload:
3. `ready` - create a non-draft PR that's ready for review

```bash
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --github-username YOUR_GITHUB_USERNAME --pr-type draft
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --username YOUR_GITHUB_USERNAME --pr-type draft
```

If you want to upload to a fork, you can do so by specifying the `fork-owner`:

```bash
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --github-username YOUR_GITHUB_USERNAME --pr-type draft --fork-owner YOUR_GITHUB_USERNAME
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --username YOUR_GITHUB_USERNAME --pr-type draft --fork-owner YOUR_GITHUB_USERNAME
```

## Providing Custom Instructions
Expand Down
135 changes: 135 additions & 0 deletions openhands/resolver/README_Gitlab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# OpenHands Gitlab Issue Resolver 🙌

Need help resolving a Gitlab issue but don't have the time to do it yourself? Let an AI agent help you out!

This tool allows you to use open-source AI agents based on [OpenHands](https://gitlab.com/all-hands-ai/openhands)
to attempt to resolve GitLab issues automatically. While it can handle multiple issues, it's primarily designed
to help you resolve one issue at a time with high quality.

Getting started is simple - just follow the instructions below.

## Manual Installation

If you prefer to run the resolver programmatically instead of using GitLab Actions, follow these steps:

1. Install the package:

```bash
pip install openhands-ai
```

2. Create a GitLab access token:
- Visit [GitLab's token settings](https://gitlab.com/-/user_settings/personal_access_tokens)
- Create a fine-grained token with these scopes:
- 'api'
- 'read_api'
- 'read_user'
- 'read_repository'
- 'write_repository'
- If you don't have push access to the target repo, you can fork it first

3. Create an API key for the [Claude API](https://www.anthropic.com/api) (recommended) or another supported LLM service

4. Set up environment variables:

```bash

# GitLab credentials

export GITLAB_TOKEN="your-gitlab-token"
export GIT_USERNAME="your-gitlab-username" # Optional, defaults to token owner

# LLM configuration

export LLM_MODEL="anthropic/claude-3-5-sonnet-20241022" # Recommended
export LLM_API_KEY="your-llm-api-key"
export LLM_BASE_URL="your-api-url" # Optional, for API proxies
```

Note: OpenHands works best with powerful models like Anthropic's Claude or OpenAI's GPT-4. While other models are supported, they may not perform as well for complex issue resolution.

## Resolving Issues

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_OR_GROUP]/[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
```

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
```

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_OR_GROUP]/[REPO] --issue-numbers [NUMBERS]
```

For example:

```bash
python -m openhands.resolver.resolve_all_issues --repo all-hands-ai/openhands --issue-numbers 100,101,102
```

## Responding to PR Comments

The resolver can also respond to comments on pull requests using:

```bash
python -m openhands.resolver.send_pull_request --issue-number PR_NUMBER --issue-type pr
```

This functionality is available both through the GitLab Actions workflow and when running the resolver locally.

## Visualizing successful PRs

To find successful PRs, you can run the following command:

```bash
grep '"success":true' output/output.jsonl | sed 's/.*\("number":[0-9]*\).*/\1/g'
```

Then you can go through and visualize the ones you'd like.

```bash
python -m openhands.resolver.visualize_resolver_output --issue-number ISSUE_NUMBER --vis-method json
```

## Uploading PRs

If you find any PRs that were successful, you can upload them.
There are three ways you can upload:

1. `branch` - upload a branch without creating a PR
2. `draft` - create a draft PR
3. `ready` - create a non-draft PR that's ready for review

```bash
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --username YOUR_GITLAB_USERNAME --pr-type draft
```

If you want to upload to a fork, you can do so by specifying the `fork-owner`:

```bash
python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --username YOUR_GITLAB_USERNAME --pr-type draft --fork-owner YOUR_GITLAB_USERNAME
```

## Providing Custom Instructions

You can customize how the AI agent approaches issue resolution by adding a `.openhands_instructions` file to the root of your repository. If present, this file's contents will be injected into the prompt for openhands edits.

## Troubleshooting

If you have any issues, please open an issue on this gitlab repo, we're happy to help!
Alternatively, you can [email us](mailto:[email protected]) or join the OpenHands Slack workspace (see [the README](/README.md) for an invite link).
Loading