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
+20 -31
View File
@@ -4,17 +4,16 @@ import { fixDoubleEscapedString } from "../utils/fixDoubleEscapedString.ts";
import type { ToolContext } from "./server.ts";
import { execute, tool } from "./shared.ts";
interface GiteaIssue {
number: number; html_url: string; title: string; state: string;
labels?: Array<{ name?: string }>; assignees?: Array<{ login: string }>;
}
export const Issue = type({
title: type.string.describe("the title of the issue"),
body: type.string.describe("the body content of the issue"),
labels: type.string
.array()
.describe("optional array of label names to apply to the issue")
.optional(),
assignees: type.string
.array()
.describe("optional array of usernames to assign to the issue")
.optional(),
labels: type.string.array().optional(),
assignees: type.string.array().optional(),
});
export function IssueTool(ctx: ToolContext) {
@@ -23,30 +22,20 @@ export function IssueTool(ctx: ToolContext) {
description: "Create a new Gitea issue",
parameters: Issue,
execute: execute(async (params) => {
const result = await ctx.gitea.rest.issue.issueCreateIssue({
owner: ctx.repo.owner,
repo: ctx.repo.name,
body: {
title: params.title,
body: fixDoubleEscapedString(params.body),
assignees: params.assignees,
},
});
log.info(`» created issue #${result.data.number}`);
const r = await ctx.gitea.request(
"POST /repos/{owner}/{repo}/issues",
{
owner: ctx.repo.owner, repo: ctx.repo.name,
title: params.title, body: fixDoubleEscapedString(params.body),
...(params.assignees ? { assignees: params.assignees } : {}),
}
);
const data = r.data as GiteaIssue;
log.info(`» created issue #${data.number}`);
return {
success: true,
number: result.data.number,
url: result.data.html_url,
title: result.data.title,
state: result.data.state,
labels: result.data.labels
?.map((l) => (typeof l === "string" ? l : l.name))
.filter((n): n is string => n !== undefined),
assignees: result.data.assignees
?.map((a) => a.login)
.filter((n): n is string => n !== undefined),
success: true, number: data.number, url: data.html_url, title: data.title, state: data.state,
labels: data.labels?.map((l) => l.name).filter((n): n is string => n !== undefined),
assignees: data.assignees?.map((a) => a.login).filter((n): n is string => n !== undefined),
};
}),
});