Add code-review-bot module: Gitea webhook, diff chunking and a Spring AI reviewer with cost controls

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RjfyTgmERTWLqzafu34Cth
This commit is contained in:
2026-10-14 06:52:09 +00:00
co-authored by Claude Sonnet 5.5
parent d5725f66ba
commit ef782060dd
23 changed files with 831 additions and 0 deletions
@@ -0,0 +1,48 @@
package com.ankurm.reviewbot;
import java.util.ArrayList;
import java.util.List;
final class Fixtures {
private Fixtures() {}
/** A small PR: one Java file with two hunks, one lockfile, and a context line at new line 1. */
static final String DIFF = """
diff --git a/src/Login.java b/src/Login.java
index 111..222 100644
--- a/src/Login.java
+++ b/src/Login.java
@@ -1,4 +1,7 @@
class Login {
+ String password = "hunter2";
+ // TODO move to vault
void run() {
+ System.out.println("login");
}
}
diff --git a/package-lock.json b/package-lock.json
index 333..444 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,2 +1,3 @@
{
+ "lockfileVersion": 3,
}
""";
/** The webhook body Gitea sends for pull_request_sync, trimmed to the fields the bot reads. */
static final String PAYLOAD = """
{"action":"synchronized","repository":{"full_name":"asmhatre/demo"},
"pull_request":{"number":7,"head":{"sha":"abc123"}}}""";
/** A synthetic diff with {@code files} files of one added line each, for the budget test. */
static String manyFiles(int files) {
List<String> parts = new ArrayList<>();
for (int i = 1; i <= files; i++) {
parts.add("diff --git a/F" + i + ".java b/F" + i + ".java\n--- a/F" + i + ".java\n+++ b/F" + i
+ ".java\n@@ -0,0 +1,1 @@\n+System.out.println(" + i + ");");
}
return String.join("\n", parts) + "\n";
}
}