From 002e809ef6d5785c270b64c5194d6b66a564597b Mon Sep 17 00:00:00 2001 From: ztimson Date: Tue, 30 Dec 2025 15:43:55 -0500 Subject: [PATCH] Updated gitea comment retrieval --- README.md | 6 ++++-- src/review.mjs | 18 +++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 31bd3d9..e7eb6d0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ### AI Agents -Automated AI-powered agents for automated reviews and code assistance +AI-powered Gitea agents for automating reviews and administration [![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/) diff --git a/src/review.mjs b/src/review.mjs index 87de01c..64ccd94 100644 --- a/src/review.mjs +++ b/src/review.mjs @@ -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}};