refactor main
This commit is contained in:
+6
-4
@@ -1,5 +1,5 @@
|
||||
import { type } from "arktype";
|
||||
import type { Context } from "../main.ts";
|
||||
import type { ToolContext } from "../main.ts";
|
||||
import { execute, tool } from "./shared.ts";
|
||||
|
||||
export const Issue = type({
|
||||
@@ -15,12 +15,12 @@ export const Issue = type({
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export function IssueTool(ctx: Context) {
|
||||
export function IssueTool(ctx: ToolContext) {
|
||||
return tool({
|
||||
name: "create_issue",
|
||||
description: "Create a new GitHub issue",
|
||||
parameters: Issue,
|
||||
execute: execute(ctx, async ({ title, body, labels, assignees }) => {
|
||||
execute: execute(async ({ title, body, labels, assignees }) => {
|
||||
const result = await ctx.octokit.rest.issues.create({
|
||||
owner: ctx.owner,
|
||||
repo: ctx.name,
|
||||
@@ -37,7 +37,9 @@ export function IssueTool(ctx: Context) {
|
||||
url: result.data.html_url,
|
||||
title: result.data.title,
|
||||
state: result.data.state,
|
||||
labels: result.data.labels?.map((label) => (typeof label === "string" ? label : label.name)),
|
||||
labels: result.data.labels?.map((label) =>
|
||||
typeof label === "string" ? label : label.name
|
||||
),
|
||||
assignees: result.data.assignees?.map((assignee) => assignee.login),
|
||||
};
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user