2e6c01670e
makes debugging easier by emitting a single `» <verb> <kind> <id>` line after every successful GitHub write (and upload) the agent performs via the Pullfrog MCP, mirroring the chevron convention used elsewhere.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { type } from "arktype";
|
|
import { log } from "../utils/cli.ts";
|
|
import type { ToolContext } from "./server.ts";
|
|
import { execute, tool } from "./shared.ts";
|
|
|
|
export const AddLabelsParams = type({
|
|
issue_number: type.number.describe("the issue or PR number to add labels to"),
|
|
labels: type.string.array().atLeastLength(1).describe("array of label names to add"),
|
|
});
|
|
|
|
export function AddLabelsTool(ctx: ToolContext) {
|
|
return tool({
|
|
name: "add_labels",
|
|
description:
|
|
"Add labels to a GitHub issue or pull request. Only use labels that already exist in the repository.",
|
|
parameters: AddLabelsParams,
|
|
execute: execute(async ({ issue_number, labels }) => {
|
|
const result = await ctx.octokit.rest.issues.addLabels({
|
|
owner: ctx.repo.owner,
|
|
repo: ctx.repo.name,
|
|
issue_number,
|
|
labels,
|
|
});
|
|
log.info(`» added labels [${labels.join(", ")}] to issue #${issue_number}`);
|
|
|
|
return {
|
|
success: true,
|
|
labels: result.data.map((label) => label.name),
|
|
};
|
|
}),
|
|
});
|
|
}
|