feat: adapt pullfrog for gitea + ollama
This commit is contained in:
+14
-20
@@ -1,7 +1,6 @@
|
||||
import { type } from "arktype";
|
||||
import { log } from "../utils/cli.ts";
|
||||
import { fixDoubleEscapedString } from "../utils/fixDoubleEscapedString.ts";
|
||||
import { patchWorkflowRunFields } from "../utils/patchWorkflowRunFields.ts";
|
||||
import type { ToolContext } from "./server.ts";
|
||||
import { execute, tool } from "./shared.ts";
|
||||
|
||||
@@ -21,38 +20,33 @@ export const Issue = type({
|
||||
export function IssueTool(ctx: ToolContext) {
|
||||
return tool({
|
||||
name: "create_issue",
|
||||
description: "Create a new GitHub issue",
|
||||
description: "Create a new Gitea issue",
|
||||
parameters: Issue,
|
||||
execute: execute(async (params) => {
|
||||
const result = await ctx.octokit.rest.issues.create({
|
||||
const result = await ctx.gitea.rest.issue.issueCreateIssue({
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
title: params.title,
|
||||
body: fixDoubleEscapedString(params.body),
|
||||
labels: params.labels ?? [],
|
||||
assignees: params.assignees ?? [],
|
||||
body: {
|
||||
title: params.title,
|
||||
body: fixDoubleEscapedString(params.body),
|
||||
assignees: params.assignees,
|
||||
},
|
||||
});
|
||||
|
||||
log.info(`» created issue #${result.data.number} (id ${result.data.id})`);
|
||||
|
||||
const nodeId = result.data.node_id;
|
||||
if (typeof nodeId === "string" && nodeId.length > 0) {
|
||||
await patchWorkflowRunFields(ctx, {
|
||||
issueNodeId: nodeId,
|
||||
});
|
||||
}
|
||||
log.info(`» created issue #${result.data.number}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
issueId: result.data.id,
|
||||
number: result.data.number,
|
||||
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
|
||||
),
|
||||
assignees: result.data.assignees?.map((assignee) => assignee.login),
|
||||
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),
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user