Skip to content

Commit 871d410

Browse files
committed
docs
1 parent 2d0977e commit 871d410

File tree

8 files changed

+88
-1
lines changed

8 files changed

+88
-1
lines changed

docs/docs.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343
}
4444
]
4545
},
46+
{
47+
"group": "Agents",
48+
"pages": [
49+
"docs/agents/overview",
50+
"docs/agents/review-agent"
51+
]
52+
},
4653
{
4754
"group": "More",
4855
"pages": [

docs/docs/agents/overview.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Agents Overview"
3+
sidebarTitle: "Overview"
4+
---
5+
6+
<Note>
7+
Have an idea for an agent that we haven't built? Submit a [feature request](https://github.com/sourcebot-dev/sourcebot/discussions/categories/feature-requests) on our GitHub
8+
</Note>
9+
10+
Agents are automations that leverage the code indexed on Sourcebot to perform a specific task. Once you've setup Sourcebot, check out the
11+
guides below to configure additional agents.
12+
13+
<CardGroup cols={2}>
14+
<Card horizontal title="Review Agent" icon="gear" href="/docs/agents/review-agent">
15+
An AI agent that reviews your PRs to identify issues
16+
</Card>
17+
</CardGroup>

docs/docs/agents/review-agent.mdx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: AI Code Review Agent
3+
sidebarTitle: AI Code Review Agent
4+
---
5+
6+
<Note>
7+
This agent sends data to OpenAI (through an API key you supply) to perform code reviews. This data includes code from the PR being reviewed, as well as additional relevant context from your
8+
codebase that the agent may fetch to perform the review.
9+
</Note>
10+
11+
This agent provides codebase-aware reviews for your PRs. For each diff, this agent fetches relevant context from Sourcebot and feeds it into an LLM for a detailed review of your changes.
12+
13+
The AI Code Review Agent is open source and packaged in [Sourcebot](https://github.com/sourcebot-dev/sourcebot). To get started using this agent, [deploy Sourcebot](http://localhost:3001/self-hosting/overview)
14+
and then follow the configuration instructions below.
15+
16+
![AI Code Review Agent Example](/images/review_agent_example.png)
17+
18+
# Configure
19+
20+
This agent currently only supports reviewing GitHub PRs. You configure the agent by creating a GitHub app, installing it into your GitHub organization, and then giving your app info to Sourcebot.
21+
22+
Before you get started, make sure you have an OpenAPI account that you can create an OpenAPI key with.
23+
24+
<Steps>
25+
<Step title="Register a GitHub app">
26+
Follow the official GitHub guide for [registering a GitHub app](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app)
27+
28+
- GitHub App name: You can make this whatever you want (ex. Sourcebot Review Agent)
29+
- Homepage URL: You can make this whatever you want (ex. https://www.sourcebot.dev/)
30+
- 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.
32+
- Permissions
33+
- Pull requests: Read
34+
- Contents: Read
35+
- Events:
36+
- Pull request
37+
</Step>
38+
<Step title="Install the GitHub app in your organization">
39+
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).
40+
41+
Select the repositories that you want to install the app into.
42+
</Step>
43+
<Step title="Configure the environment variables in Sourcebot">
44+
Sourcebot requires the following environment variables to begin reviewing PRs through your new GitHub app:
45+
46+
- `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)
47+
- `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)
48+
- `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)
49+
![GitHub App Private Key](/images/github_app_private_key.png)
50+
- `OPENAI_API_KEY`: Your OpenAI API key
51+
</Step>
52+
<Step title="Verify configuration">
53+
Navigate to the agents page by pressing `Agents` in the Sourcebot nav menu. If you've configured your environment variables you'll see the following:
54+
55+
![Review Agent Configured](/images/review_agent_configured.png)
56+
</Step>
57+
</Steps>
21.7 KB
Loading
70.2 KB
Loading
211 KB
Loading

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Link from "next/link";
22
import { NavigationMenu } from "../components/navigationMenu";
33
import { FaCogs } from "react-icons/fa";
4-
import { MdRocketLaunch } from "react-icons/md";
54
import { env } from "@/env.mjs";
65

76
const agents = [

packages/web/src/app/[domain]/components/navigationMenu.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export const NavigationMenu = async ({
5959
</NavigationMenuLink>
6060
</Link>
6161
</NavigationMenuItem>
62+
<NavigationMenuItem>
63+
<Link href={`/${domain}/agents`} legacyBehavior passHref>
64+
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
65+
Agents
66+
</NavigationMenuLink>
67+
</Link>
68+
</NavigationMenuItem>
6269
<NavigationMenuItem>
6370
<Link href={`/${domain}/repos`} legacyBehavior passHref>
6471
<NavigationMenuLink className={navigationMenuTriggerStyle()}>

0 commit comments

Comments
 (0)