Updated gitea comment retrieval

This commit is contained in:
2025-12-30 15:43:55 -05:00
parent 397c9aeb90
commit 002e809ef6
2 changed files with 11 additions and 13 deletions

View File

@@ -9,7 +9,7 @@
### AI Agents
<!-- Description -->
Automated AI-powered agents for automated reviews and code assistance
AI-powered Gitea agents for automating reviews and administration
<!-- Repo badges -->
[![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/ai-agents/tags&query=$[0].name)](https://git.zakscode.com/ztimson/ai-agents/tags)
@@ -37,7 +37,9 @@ Automated AI-powered agents for automated reviews and code assistance
## About
Automated code agents that uses AI to analyze git diffs and provide inline comments on pull requests. Supports Anthropic, OpenAI, and Ollama models with tool-based reviewing for precise feedback.
Only supports Gitea
Use LLM models from Anthropic, OpenAI, or Ollama to automate ticket refinement, code reviews, and releases.
### Built With
[![Docker](https://img.shields.io/badge/Docker-384d54?style=for-the-badge&logo=docker)](https://docker.com/)

View File

@@ -35,19 +35,15 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
return process.exit();
}
let existingComments = '';
let existingComments = 'Existing Comments:\n';
if(git && pr) {
const res = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {
const reviews = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {
headers: {'Authorization': `token ${auth}`}
});
if(res.ok) {
const reviews = await res.json();
const allComments = reviews.flatMap(r => r.comments || []);
if(allComments.length) {
existingComments = '\n\nExisting review comments (DO NOT repeat these):\n' +
allComments.map(c => `- ${c.path}:${c.line || c.position}: ${c.body}`).join('\n');
}
}
}).then(resp => resp.ok ? resp.json() : []);
const comments = await Promise.all(reviews.map(r => fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews/${r.id}/comments`, {
headers: {'Authorization': `token ${auth}`}
}).then(resp => resp.ok ? resp.json() : [])));
existingComments += comments.flatten().map(c => `${c.path}:${c.position}\n${c.body}`).join('\n\n');
}
let options = {ollama: {model, host}};