36 lines
911 B
TypeScript
36 lines
911 B
TypeScript
import { type } from "arktype";
|
|
import { contextualize, tool } from "./shared.ts";
|
|
|
|
export const PullRequestInfo = type({
|
|
pull_number: type.number.describe("The pull request number to fetch"),
|
|
});
|
|
|
|
export const PullRequestInfoTool = tool({
|
|
name: "get_pull_request",
|
|
description: "Retrieve minimal information for a specific pull request by number.",
|
|
parameters: PullRequestInfo,
|
|
execute: contextualize(async ({ pull_number }, ctx) => {
|
|
const pr = await ctx.octokit.rest.pulls.get({
|
|
owner: ctx.owner,
|
|
repo: ctx.name,
|
|
pull_number,
|
|
});
|
|
|
|
const data = pr.data;
|
|
|
|
const baseBranch = data.base.ref;
|
|
const headBranch = data.head.ref;
|
|
|
|
return {
|
|
number: data.number,
|
|
url: data.html_url,
|
|
title: data.title,
|
|
state: data.state,
|
|
draft: data.draft,
|
|
merged: data.merged,
|
|
base: baseBranch,
|
|
head: headBranch,
|
|
};
|
|
}),
|
|
});
|