Skip to content

Commit 2307106

Browse files
committed
feedback and improved docs for review agent
1 parent c586558 commit 2307106

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

docs/docs/agents/review-agent.mdx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Before you get started, make sure you have an OpenAPI account that you can creat
2828
- GitHub App name: You can make this whatever you want (ex. Sourcebot Review Agent)
2929
- Homepage URL: You can make this whatever you want (ex. https://www.sourcebot.dev/)
3030
- Webhook URL (**IMPORTANT**): You must set this to point to your Sourcebot deployment at /api/webhook (ex. https://sourcebot.aperture.com/api/webhook). Your Sourcebot deployment must be able to accept requests from GitHub
31-
(either github.com or your self-hosted enterprise server) for this to work. If you're running Sourcebot locally, you can [use smee](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-2-get-a-webhook-proxy-url) to [forward webhooks](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-6-start-your-server) to you local deployment.
31+
(either github.com or your self-hosted enterprise server) for this to work. If you're running Sourcebot locally, you can [use smee](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-2-get-a-webhook-proxy-url) to [forward webhooks](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-6-start-your-server) to your local deployment.
3232
- Permissions
3333
- Pull requests: Read & Write
3434
- Issues: Read & Write
@@ -38,20 +38,44 @@ Before you get started, make sure you have an OpenAPI account that you can creat
3838
- Issue comment
3939
</Step>
4040
<Step title="Install the GitHub app in your organization">
41-
Navigate to your new GitHub app's page and press `Install`. You can find this in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings).
42-
43-
Select the repositories that you want to install the app into.
41+
Navigate to your new [GitHub app's page](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) and press `Install`
4442
</Step>
4543
<Step title="Configure the environment variables in Sourcebot">
4644
Sourcebot requires the following environment variables to begin reviewing PRs through your new GitHub app:
4745

4846
- `GITHUB_APP_ID`: The client ID of your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings)
4947
- `GITHUB_APP_WEBHOOK_SECRET`: A random webhook secret that you've set in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings). This can be anything (ex. `python -c "import secrets; print(secrets.token_hex(10))"` to generate a random secret)
50-
- `GITHUB_APP_PRIVATE_KEY_PATH`: The path to your app's private key. You can generate a private key file for your app in the [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings)
48+
- `GITHUB_APP_PRIVATE_KEY_PATH`: The path to your app's private key. If you're running Sourcebot from a container, this is the path to this file from within your container
49+
(ex `/data/review-agent-key.pem`). You must copy the private key file into the directory you mount to Sourcebot (similar to the config file).
50+
51+
You can generate a private key file for your app in the [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings). You must copy this private key file into the
52+
directory that you mount to Sourcebot
5153
![GitHub App Private Key](/images/github_app_private_key.png)
5254
- `OPENAI_API_KEY`: Your OpenAI API key
5355
- `REVIEW_AGENT_AUTO_REVIEW_ENABLED` (default: `false`): If enabled, the review agent will automatically review any new or updated PR. If disabled, you must invoke it using the command defined by `REVIEW_AGENT_REVIEW_COMMAND`
5456
- `REVIEW_AGENT_REVIEW_COMMAND` (default: `review`): The command that invokes the review agent (ex. `/review`) when a user comments on the PR. Don't include the slash character in this value.
57+
58+
You can find an example docker compose file below. This docker compose file is placed in `~/sourcebot_review_agent_workspace`, and I'm mounting that directory to Sourcebot. The
59+
config file and the app's private key file are also placed in this directory. The paths to these files are given to Sourcebot relative to `/data` since that's the directory
60+
in Sourcebot that I'm mounting to.
61+
62+
```yaml
63+
services:
64+
sourcebot:
65+
image: ghcr.io/sourcebot-dev/sourcebot:latest
66+
pull_policy: always
67+
container_name: sourcebot
68+
ports:
69+
- "3000:3000"
70+
volumes:
71+
- "/Users/michael/sourcebot_review_agent_workspace:/data"
72+
environment:
73+
CONFIG_PATH: "/data/config.json"
74+
GITHUB_APP_ID: "my-github-app-id"
75+
GITHUB_APP_WEBHOOK_SECRET: "my-github-app-webhook-secret"
76+
GITHUB_APP_PRIVATE_KEY_PATH: "/data/review-agent-key.pem"
77+
OPENAI_API_KEY: "sk-proj-my-open-api-key"
78+
```
5579
</Step>
5680
<Step title="Verify configuration">
5781
Navigate to the agents page by pressing `Agents` in the Sourcebot nav menu. If you've configured your environment variables correctly you'll see the following:

packages/web/src/app/[domain]/agents/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const agents = [
77
{
88
id: "review-agent",
99
name: "Review Agent",
10-
description: "An agent that reviews your PRs. Uses the code indexed on Sourcebot to provide codebase wide context.",
10+
description: "An AI code review agent that reviews your PRs. Uses the code indexed on Sourcebot to provide codebase-wide context.",
1111
requiredEnvVars: ["GITHUB_APP_ID", "GITHUB_APP_WEBHOOK_SECRET", "GITHUB_APP_PRIVATE_KEY_PATH", "OPENAI_API_KEY"],
1212
configureUrl: "https://docs.sourcebot.dev/docs/agents/review-agent"
1313
},

packages/web/src/app/api/(server)/webhook/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const POST = async (request: NextRequest) => {
5151
const body = await request.json();
5252
const headers = Object.fromEntries(request.headers.entries());
5353

54-
const githubEvent = headers['x-github-event'];
54+
const githubEvent = headers['x-github-event'] || headers['X-GitHub-Event'];
5555
if (githubEvent) {
5656
console.log('GitHub event received:', githubEvent);
5757

0 commit comments

Comments
 (0)