import { RPC, RpcError } from "./protocol";
import type { JsonObject, McpCaller } from "./protocol";
import { callTool } from "./tools";
import { untrustedBlock } from "./untrusted";
export const PROMPTS = [
{
name: "review-pr",
title: "Review a pull request",
description: "Review a pull request's diff and submit a review with line comments.",
arguments: [
{ name: "owner", required: true },
{ name: "repo", required: true },
{ name: "number", description: "Pull request number", required: true },
],
},
{
name: "fix-ci",
title: "Fix failing CI",
description: "Investigate a failing CI run, fix the code on a branch and re-run CI.",
arguments: [
{ name: "owner", required: true },
{ name: "repo", required: true },
{ name: "run", description: "Run number", required: true },
],
},
];
const noHooks = { signal: new AbortController().signal, progress: () => undefined };
function argument(args: JsonObject, name: string): string {
const value = args[name];
if (typeof value !== "string" || value.trim() === "")
throw new RpcError(RPC.invalidParams, `Missing argument ${name}`);
return value.trim();
}
async function fetchStructured(caller: McpCaller, name: string, args: JsonObject): Promise<string> {
const result = await callTool(caller, { name, arguments: args }, noHooks);
if (result.isError) {