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:
@@ -0,0 +1,23 @@
|
||||
# code-review-bot
|
||||
|
||||
Companion code for *Build an AI Code-Review Bot in Java (Gitea/GitHub Webhook + Spring AI)* on
|
||||
[ankurm.com](https://ankurm.com). A webhook receiver that checks Gitea's HMAC signature, a diff chunker that numbers
|
||||
lines of the new file, a Spring AI `ChatClient` that reviews each chunk, and a posting step that keeps only comments
|
||||
that can be attached to a line. No API key: the tests use `ScriptedChatModel`, a scripted `ChatModel`.
|
||||
|
||||
```bash
|
||||
mvn test -pl code-review-bot # rewrites output/*.txt
|
||||
```
|
||||
|
||||
| File | Role |
|
||||
|---|---|
|
||||
| `WebhookController` | Verifies `X-Gitea-Signature` over the raw body, filters events, queues the review and answers `202` |
|
||||
| `Hmac` | Bare lowercase hex HMAC-SHA256 with a constant-time comparison |
|
||||
| `DiffChunker` | Unified diff to chunks: file boundaries respected, new-file line numbers, lockfiles and binaries skipped |
|
||||
| `ReviewService` | The prompt, the content-keyed cache, the chunk cap, the severity filter, the "is this an added line?" guard |
|
||||
| `GitHost`, `GiteaHost` | The two calls the bot needs; the Gitea endpoints were checked against Gitea 1.27.3's swagger. `GiteaHost` is not exercised against a live server by the tests |
|
||||
|
||||
Not covered here: running it against a real model, GitHub's payload (the `X-Hub-Signature-256` header carries a
|
||||
`sha256=` prefix), and review threading on later pushes.
|
||||
|
||||
Verified with Spring Boot 4.1.1, Spring AI `spring-ai-client-chat` **2.0.1**, JDK 25, JUnit 6.1.3.
|
||||
Reference in New Issue
Block a user