Skip to content

Commit 79dd288

Browse files
committed
feedback
1 parent a81cd24 commit 79dd288

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ export const POST = async (request: NextRequest) => {
3131
const body = await request.json();
3232
const headers = Object.fromEntries(request.headers.entries());
3333

34-
console.log('Webhook request headers:', headers);
35-
console.log('Webhook request body:', JSON.stringify(body, null, 2));
36-
3734
const githubEvent = headers['x-github-event'];
3835
if (githubEvent) {
3936
console.log('GitHub event received:', githubEvent);
@@ -44,8 +41,6 @@ export const POST = async (request: NextRequest) => {
4441
}
4542

4643
if (isPullRequestEvent(githubEvent, body)) {
47-
console.log('Received pull request event:', body);
48-
4944
if (!body.installation) {
5045
console.error('Received github pull request event but installation is not present');
5146
return Response.json({ status: 'ok' });
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { Octokit } from "octokit";
22
import { WebhookEventDefinition } from "@octokit/webhooks/types";
3-
import { generate_pr_reviews } from "@/features/agents/review-agent/nodes/generate_pr_reviews";
4-
import { github_push_pr_reviews } from "@/features/agents/review-agent/nodes/github_push_pr_reviews";
5-
import { github_pr_parser } from "@/features/agents/review-agent/nodes/github_pr_parser";
3+
import { generatePrReviews } from "@/features/agents/review-agent/nodes/generatePrReview";
4+
import { githubPushPrReviews } from "@/features/agents/review-agent/nodes/githubPushPrReviews";
5+
import { githubPrParser } from "@/features/agents/review-agent/nodes/githubPrParser";
66
import { env } from "@/env.mjs";
77

88
const rules = [
99
"Do NOT provide general feedback, summaries, explanations of changes, or praises for making good additions.",
1010
"Do NOT provide any advice that is not actionable or directly related to the changes.",
11+
"Do NOT provide any comments or reviews on code that you believe is good, correct, or a good addition. Your job is only to identify issues and provide feedback on how to fix them.",
12+
"If a review for a chunk contains different reviews at different line ranges, return a seperate review object for each line range.",
1113
"Focus solely on offering specific, objective insights based on the given context and refrain from making broad comments about potential impacts on the system or question intentions behind the changes.",
1214
"Keep comments concise and to the point. Every comment must highlight a specific issue and provide a clear and actionable solution to the developer.",
1315
"If there are no issues found on a line range, do NOT respond with any comments. This includes comments such as \"No issues found\" or \"LGTM\"."
@@ -21,7 +23,7 @@ export async function processGitHubPullRequest(octokit: Octokit, payload: Webhoo
2123
return;
2224
}
2325

24-
const prPayload = await github_pr_parser(octokit, payload);
25-
const fileDiffReviews = await generate_pr_reviews(prPayload, rules);
26-
await github_push_pr_reviews(octokit, prPayload, fileDiffReviews);
26+
const prPayload = await githubPrParser(octokit, payload);
27+
const fileDiffReviews = await generatePrReviews(prPayload, rules);
28+
await githubPushPrReviews(octokit, prPayload, fileDiffReviews);
2729
}

packages/web/src/features/agents/review-agent/nodes/fetch_file_content.ts renamed to packages/web/src/features/agents/review-agent/nodes/fetchFileContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { sourcebot_context, sourcebot_pr_payload } from "@/features/agents/revie
22
import { fileSourceResponseSchema } from "@/features/search/schemas";
33
import { base64Decode } from "@/lib/utils";
44

5-
export const fetch_file_content = async (pr_payload: sourcebot_pr_payload, filename: string): Promise<sourcebot_context> => {
5+
export const fetchFileContent = async (pr_payload: sourcebot_pr_payload, filename: string): Promise<sourcebot_context> => {
66
console.log("Executing fetch_file_content");
77

88
const repoPath = pr_payload.hostDomain + "/" + pr_payload.owner + "/" + pr_payload.repo;

packages/web/src/features/agents/review-agent/nodes/generate_diff_review_prompt.ts renamed to packages/web/src/features/agents/review-agent/nodes/generateDiffReviewPrompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sourcebot_diff, sourcebot_context, sourcebot_diff_review_schema } from "@/features/agents/review-agent/types";
22
import { zodToJsonSchema } from "zod-to-json-schema";
33

4-
export const generate_diff_review_prompt = async (diff: sourcebot_diff, context: sourcebot_context[], rules: string[]) => {
4+
export const generateDiffReviewPrompt = async (diff: sourcebot_diff, context: sourcebot_context[], rules: string[]) => {
55
console.log("Executing generate_diff_review_prompt");
66

77
const prompt = `

packages/web/src/features/agents/review-agent/nodes/generate_pr_reviews.ts renamed to packages/web/src/features/agents/review-agent/nodes/generatePrReview.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { sourcebot_pr_payload, sourcebot_diff_review, sourcebot_file_diff_review, sourcebot_context } from "@/features/agents/review-agent/types";
2-
import { generate_diff_review_prompt } from "@/features/agents/review-agent/nodes/generate_diff_review_prompt";
3-
import { invoke_diff_review_llm } from "@/features/agents/review-agent/nodes/invoke_diff_review_llm";
4-
import { fetch_file_content } from "@/features/agents/review-agent/nodes/fetch_file_content";
2+
import { generateDiffReviewPrompt } from "@/features/agents/review-agent/nodes/generateDiffReviewPrompt";
3+
import { invokeDiffReviewLlm } from "@/features/agents/review-agent/nodes/invokeDiffReviewLlm";
4+
import { fetchFileContent } from "@/features/agents/review-agent/nodes/fetchFileContent";
55

6-
export const generate_pr_reviews = async (pr_payload: sourcebot_pr_payload, rules: string[]): Promise<sourcebot_file_diff_review[]> => {
6+
export const generatePrReviews = async (pr_payload: sourcebot_pr_payload, rules: string[]): Promise<sourcebot_file_diff_review[]> => {
77
console.log("Executing generate_pr_reviews");
88

99
const file_diff_reviews: sourcebot_file_diff_review[] = [];
@@ -12,7 +12,7 @@ export const generate_pr_reviews = async (pr_payload: sourcebot_pr_payload, rule
1212

1313
for (const diff of file_diff.diffs) {
1414
try {
15-
const fileContentContext = await fetch_file_content(pr_payload, file_diff.to);
15+
const fileContentContext = await fetchFileContent(pr_payload, file_diff.to);
1616
const context: sourcebot_context[] = [
1717
{
1818
type: "pr_title",
@@ -27,9 +27,9 @@ export const generate_pr_reviews = async (pr_payload: sourcebot_pr_payload, rule
2727
fileContentContext,
2828
];
2929

30-
const prompt = await generate_diff_review_prompt(diff, context, rules);
30+
const prompt = await generateDiffReviewPrompt(diff, context, rules);
3131

32-
const diffReview = await invoke_diff_review_llm(prompt);
32+
const diffReview = await invokeDiffReviewLlm(prompt);
3333
reviews.push(diffReview);
3434
} catch (error) {
3535
console.error(`Error fetching file content for ${file_diff.to}: ${error}`);

packages/web/src/features/agents/review-agent/nodes/github_pr_parser.ts renamed to packages/web/src/features/agents/review-agent/nodes/githubPrParser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WebhookEventDefinition } from "@octokit/webhooks/types";
33
import parse from "parse-diff";
44
import { Octokit } from "octokit";
55

6-
export const github_pr_parser = async (octokit: Octokit, payload: WebhookEventDefinition<"pull-request-opened"> | WebhookEventDefinition<"pull-request-synchronize">): Promise<sourcebot_pr_payload> => {
6+
export const githubPrParser = async (octokit: Octokit, payload: WebhookEventDefinition<"pull-request-opened"> | WebhookEventDefinition<"pull-request-synchronize">): Promise<sourcebot_pr_payload> => {
77
console.log("Executing github_pr_parser");
88

99
if (!payload.installation) {
@@ -25,12 +25,12 @@ export const github_pr_parser = async (octokit: Octokit, payload: WebhookEventDe
2525

2626
for (const change of chunk.changes) {
2727
if (change.type === "normal") {
28-
oldSnippet += change.ln1 + ":" + change.content;
29-
newSnippet += change.ln2 + ":" + change.content;
28+
oldSnippet += change.ln1 + ":" + change.content + "\n";
29+
newSnippet += change.ln2 + ":" + change.content + "\n";
3030
} else if (change.type === "add") {
31-
newSnippet += change.ln + ":" + change.content;
31+
newSnippet += change.ln + ":" + change.content + "\n";
3232
} else if (change.type === "del") {
33-
oldSnippet += change.ln + ":" + change.content;
33+
oldSnippet += change.ln + ":" + change.content + "\n";
3434
}
3535
}
3636

packages/web/src/features/agents/review-agent/nodes/github_push_pr_reviews.ts renamed to packages/web/src/features/agents/review-agent/nodes/githubPushPrReviews.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Octokit } from "octokit";
22
import { sourcebot_pr_payload, sourcebot_file_diff_review } from "@/features/agents/review-agent/types";
33

4-
export const github_push_pr_reviews = async (octokit: Octokit, pr_payload: sourcebot_pr_payload, file_diff_reviews: sourcebot_file_diff_review[]) => {
4+
export const githubPushPrReviews = async (octokit: Octokit, pr_payload: sourcebot_pr_payload, file_diff_reviews: sourcebot_file_diff_review[]) => {
55
console.log("Executing github_push_pr_reviews");
66

77
try {

packages/web/src/features/agents/review-agent/nodes/invoke_diff_review_llm.ts renamed to packages/web/src/features/agents/review-agent/nodes/invokeDiffReviewLlm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import OpenAI from "openai";
22
import { sourcebot_diff_review_schema, sourcebot_diff_review } from "@/features/agents/review-agent/types";
33
import { env } from "@/env.mjs";
44

5-
export const invoke_diff_review_llm = async (prompt: string): Promise<sourcebot_diff_review> => {
5+
export const invokeDiffReviewLlm = async (prompt: string): Promise<sourcebot_diff_review> => {
66
console.log("Executing invoke_diff_review_llm");
77

88
if (!env.OPENAI_API_KEY) {
@@ -14,6 +14,8 @@ export const invoke_diff_review_llm = async (prompt: string): Promise<sourcebot_
1414
apiKey: env.OPENAI_API_KEY,
1515
});
1616

17+
console.log("Prompt: ", prompt);
18+
1719
try {
1820
const completion = await openai.chat.completions.create({
1921
model: "gpt-4.1-mini",

0 commit comments

Comments
 (0)