fix: issues with pagination not resolving correct url templates

This commit is contained in:
2026-05-31 01:43:42 -05:00
parent 2aca1a3aa3
commit 0438688e32
14 changed files with 287 additions and 467 deletions
+9 -15
View File
@@ -2,6 +2,8 @@ import { type } from "arktype";
import type { ToolContext } from "./server.ts";
import { execute, tool } from "./shared.ts";
interface GiteaComment { id: number; body?: string | null; user?: { login?: string } }
export const GetIssueComments = type({
issue_number: type.number.describe("The issue number to get comments for"),
});
@@ -9,26 +11,18 @@ export const GetIssueComments = type({
export function GetIssueCommentsTool(ctx: ToolContext) {
return tool({
name: "get_issue_comments",
description:
"Get all comments for a Gitea issue or PR. " +
"Example: `get_issue_comments({ issue_number: 1234 })`.",
description: "Get all comments for a Gitea issue or PR. Example: `get_issue_comments({ issue_number: 1234 })`.",
parameters: GetIssueComments,
execute: execute(async ({ issue_number }) => {
ctx.toolState.issueNumber = issue_number;
const comments = await ctx.gitea.paginate(ctx.gitea.rest.issue.issueGetComments, {
owner: ctx.repo.owner,
repo: ctx.repo.name,
index: issue_number,
});
const r = await ctx.gitea.request(
"GET /repos/{owner}/{repo}/issues/{index}/comments",
{ owner: ctx.repo.owner, repo: ctx.repo.name, index: issue_number, limit: 50 }
);
const comments = r.data as GiteaComment[];
return {
issue_number,
comments: comments.map((c) => ({
id: c.id,
body: c.body,
user: c.user?.login,
})),
comments: comments.map((c) => ({ id: c.id, body: c.body, user: c.user?.login })),
count: comments.length,
};
}),