diff --git a/docs.json b/docs.json index 83a71590..f7cab657 100644 --- a/docs.json +++ b/docs.json @@ -235,6 +235,9 @@ { "group": "GitHub Workflows", "pages": [ + "sdk/guides/github-workflows/assign-reviews", + "sdk/guides/github-workflows/pr-review", + "sdk/guides/github-workflows/todo-management" ] } ] diff --git a/sdk/guides/github-workflows/assign-reviews.mdx b/sdk/guides/github-workflows/assign-reviews.mdx new file mode 100644 index 00000000..2fbdee28 --- /dev/null +++ b/sdk/guides/github-workflows/assign-reviews.mdx @@ -0,0 +1,30 @@ +--- +title: Assign Reviews +description: Automatically assign relevant reviewers to pull requests using OpenHands Agent +--- + + +This example is available on GitHub: [.github/workflows/assign-reviews.yml](https://github.com/OpenHands/agent-sdk/blob/main/.github/workflows/assign-reviews.yml) + + +Automatically assign relevant reviewers to pull requests based on code changes and file ownership using OpenHands Agent. +This workflow uses the basic action workflow template that allows to perform any basic action with the OpenHands Agent. + +## Quick Start + +```bash +# 1. Copy workflow to your repository +cp examples/03_github_workflows/04_assign_reviews/workflow.yml .github/workflows/assign-reviews.yml + +# 2. Configure secrets in GitHub Settings → Secrets +# Add: LLM_API_KEY + +# 3. Configure GitHub Actions permissions +# Settings → Actions → General → Workflow permissions +# Enable: "Read and write permissions" +``` + +## Related Files + +- [Basic Action Agent Script](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/01_basic_action/agent_script.py) +- [Workflow File](https://github.com/OpenHands/agent-sdk/blob/main/.github/workflows/assign-reviews.yml) diff --git a/sdk/guides/github-workflows/pr-review.mdx b/sdk/guides/github-workflows/pr-review.mdx new file mode 100644 index 00000000..824dbb3b --- /dev/null +++ b/sdk/guides/github-workflows/pr-review.mdx @@ -0,0 +1,39 @@ +--- +title: PR Review +description: Use OpenHands Agent to generate meaningful pull request review +--- + + +This example is available on GitHub: [examples/03_github_workflows/02_pr_review/](https://github.com/OpenHands/agent-sdk/tree/main/examples/03_github_workflows/02_pr_review) + + +Automatically review pull requests when labeled with `review-this`, providing feedback on code quality, security, and best practices. + +```yaml icon="yaml" expandable agent-sdk/examples/03_github_workflows/01_basic_action/workflow.yml + +``` + +## Quick Start + +```bash +# 1. Copy workflow to your repository +cp examples/03_github_workflows/02_pr_review/workflow.yml .github/workflows/pr-review.yml + +# 2. Configure secrets in GitHub Settings → Secrets +# Add: LLM_API_KEY + +# 3. Create a "review-this" label in your repository +# Go to Issues → Labels → New label +``` + +## Features + +- **Automatic Trigger** - Reviews start when `review-this` label is added and is posted on the PR in only 2 or 3 minutes +- **Comprehensive Analysis** - Analyzes the changes given the repository context. Covers code quality, security, best practices +- **GitHub Integration** - Posts comments directly to the PR + +## Related Files + +- [Agent Script](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/02_pr_review/agent_script.py) +- [Workflow File](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/02_pr_review/workflow.yml) +- [Prompt Template](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/02_pr_review/prompt.py) diff --git a/sdk/guides/github-workflows/todo-management.mdx b/sdk/guides/github-workflows/todo-management.mdx new file mode 100644 index 00000000..9d0426fb --- /dev/null +++ b/sdk/guides/github-workflows/todo-management.mdx @@ -0,0 +1,48 @@ +--- +title: TODO Management +description: Implement TODOs using OpenHands Agent +--- + + +This example is available on GitHub: [examples/03_github_workflows/03_todo_management/](https://github.com/OpenHands/agent-sdk/tree/main/examples/03_github_workflows/03_todo_management) + + +Scan your codebase for TODO comments and let the OpenHands Agent implement them, creating a pull request for each TODO and picking relevant reviewers based on code changes and file ownership + +## Quick Start + +```bash +# 1. Copy workflow to your repository +cp examples/03_github_workflows/03_todo_management/workflow.yml .github/workflows/todo-management.yml + +# 2. Configure secrets in GitHub Settings → Secrets +# Add: LLM_API_KEY + +# 3. Configure GitHub Actions permissions +# Settings → Actions → General → Workflow permissions +# Enable: "Read and write permissions" + "Allow GitHub Actions to create and approve pull requests" + +# 4. Add TODO comments to your code +# Example: # TODO(openhands): Add input validation for user email +``` + +The workflow is configurable and any identifier can be used in place of `TODO(openhands)` + +## Features + +- **Scanning** - Finds matching TODO comments with configurable identifiers and extracts the TODO description. +- **Implementation** - Sends the TODO description to the OpenHands Agent that automatically implements it +- **PR Management** - Creates feature branches, pull requests and picks most relevant reviewers + +## Best Practices + +- **Start Small** - Begin with `MAX_TODOS: 1` to test the workflow +- **Clear Descriptions** - Write descriptive TODO comments +- **Review PRs** - Always review the generated PRs before merging + +## Related Documentation + +- [Agent Script](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/03_todo_management/agent_script.py) +- [Scanner Script](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/03_todo_management/scanner.py) +- [Workflow File](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/03_todo_management/workflow.yml) +- [Prompt Template](https://github.com/OpenHands/agent-sdk/blob/main/examples/03_github_workflows/03_todo_management/prompt.py)