42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { type } from "arktype";
|
|
import type { Context } from "../main.ts";
|
|
import { execute, tool } from "./shared.ts";
|
|
|
|
export const GetIssueComments = type({
|
|
issue_number: type.number.describe("The issue number to get comments for"),
|
|
});
|
|
|
|
export function GetIssueCommentsTool(ctx: Context) {
|
|
return tool({
|
|
name: "get_issue_comments",
|
|
description:
|
|
"Get all comments for a GitHub issue. Returns all comments including the issue body and all subsequent discussion comments.",
|
|
parameters: GetIssueComments,
|
|
execute: execute(ctx, async ({ issue_number }) => {
|
|
// set issue context
|
|
ctx.toolState.issueNumber = issue_number;
|
|
|
|
const comments = await ctx.octokit.paginate(ctx.octokit.rest.issues.listComments, {
|
|
owner: ctx.owner,
|
|
repo: ctx.name,
|
|
issue_number,
|
|
});
|
|
|
|
return {
|
|
issue_number,
|
|
comments: comments.map((comment) => ({
|
|
id: comment.id,
|
|
body: comment.body,
|
|
user: comment.user?.login,
|
|
created_at: comment.created_at,
|
|
updated_at: comment.updated_at,
|
|
html_url: comment.html_url,
|
|
author_association: comment.author_association,
|
|
reactions: comment.reactions,
|
|
})),
|
|
count: comments.length,
|
|
};
|
|
}),
|
|
});
|
|
}
|