refactor main

This commit is contained in:
David Blass
2025-12-17 16:20:46 -05:00
parent 1f1c1602c5
commit 90ed2648be
24 changed files with 638 additions and 546 deletions
+6 -4
View File
@@ -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),
};
}),