From 3a34883ec7a4d11a0e19385567976b0c17669103 Mon Sep 17 00:00:00 2001 From: Hugo Nijhuis Date: Wed, 13 May 2026 17:31:57 +0200 Subject: [PATCH] fix pr list --- .opencode/tools/tea-pr.ts | 99 +++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/.opencode/tools/tea-pr.ts b/.opencode/tools/tea-pr.ts index 8d8e916..a411a03 100644 --- a/.opencode/tools/tea-pr.ts +++ b/.opencode/tools/tea-pr.ts @@ -1,68 +1,73 @@ -import { tool } from "@opencode-ai/plugin" -import { $ } from "bun" +import { tool } from "@opencode-ai/plugin"; +import { $ } from "bun"; export const prList = tool({ - description: "List pull requests with their current state, useful for tracking work in progress or finding PRs to review", + description: + "List pull requests with their current state, useful for tracking work in progress or finding PRs to review", args: { - state: tool.schema.enum(["open", "closed", "all"]).default("open").describe("Filter by state"), - author: tool.schema.string().optional().describe("Filter by author username"), + state: tool.schema + .enum(["open", "closed", "all"]) + .default("open") + .describe("Filter by state"), limit: tool.schema.number().default(30).describe("Number of PRs to return"), }, async execute(args, context) { try { - const cmd = args.author - ? $`tea pr list --output json --state ${args.state} --author ${args.author} --limit ${args.limit}` - : $`tea pr list --output json --state ${args.state} --limit ${args.limit}` - - const result = await cmd.text() - return result + const cmd = $`tea pr list --output json --state ${args.state} --limit ${args.limit ?? 30}`; + + const result = await cmd.text(); + return result; } catch (error: any) { return { error: "Failed to list pull requests", message: error.message, stderr: error.stderr?.toString(), - } + }; } }, -}) +}); export const prCreate = tool({ - description: "Create a new pull request with title, body, base branch, head branch, and optional labels and milestone", + description: + "Create a new pull request with title, body, base branch, head branch, and optional labels and milestone", args: { title: tool.schema.string().describe("PR title"), body: tool.schema.string().optional().describe("PR description/body"), base: tool.schema.string().describe("Base branch name"), head: tool.schema.string().describe("Head branch name"), - labels: tool.schema.array(tool.schema.string()).optional().describe("Comma-separated list of label names"), + labels: tool.schema + .array(tool.schema.string()) + .optional() + .describe("Comma-separated list of label names"), milestone: tool.schema.string().optional().describe("Milestone name"), }, async execute(args, context) { try { - let cmd = $`tea pr create --output json --title ${args.title} --base ${args.base} --head ${args.head}` - + let cmd = $`tea pr create --output json --title ${args.title} --base ${args.base} --head ${args.head}`; + if (args.body) { - cmd = cmd`--body ${args.body}` + cmd = cmd`--body ${args.body}`; } - + if (args.labels) { - cmd = cmd`--labels ${args.labels.join(",")}` + cmd = cmd`--labels ${args.labels.join(",")}`; } - + if (args.milestone) { - cmd = cmd`--milestone ${args.milestone}` + cmd = cmd`--milestone ${args.milestone}`; } - - const result = await cmd.text() - return result + + const result = await cmd.text(); + return result; } catch (error: any) { return { error: "Failed to create pull request", message: error.message, stderr: error.stderr?.toString(), - } + }; } }, -}) +}); export const prCheckout = tool({ description: "Checkout a pull request locally to work on it", @@ -71,20 +76,20 @@ export const prCheckout = tool({ }, async execute(args, context) { try { - const result = await $`tea pr checkout ${args.prNumber}`.text() + const result = await $`tea pr checkout ${args.prNumber}`.text(); return { success: true, message: result, - } + }; } catch (error: any) { return { error: "Failed to checkout pull request", message: error.message, stderr: error.stderr?.toString(), - } + }; } }, -}) +}); export const prMerge = tool({ description: "Merge a pull request using rebase merge style", @@ -95,43 +100,45 @@ export const prMerge = tool({ }, async execute(args, context) { try { - let cmd = $`tea pr merge --style rebase --output json ${args.prNumber}` - + let cmd = $`tea pr merge --style rebase --output json ${args.prNumber}`; + if (args.title) { - cmd = cmd`--title ${args.title}` + cmd = cmd`--title ${args.title}`; } - + if (args.message) { - cmd = cmd`--message ${args.message}` + cmd = cmd`--message ${args.message}`; } - - const result = await cmd.text() - return result + + const result = await cmd.text(); + return result; } catch (error: any) { return { error: "Failed to merge pull request", message: error.message, stderr: error.stderr?.toString(), - } + }; } }, -}) +}); export const prDetails = tool({ - description: "Get detailed information about a specific pull request including review status and comments", + description: + "Get detailed information about a specific pull request including review status and comments", args: { prNumber: tool.schema.number().describe("Pull request number"), }, async execute(args, context) { try { - const result = await $`tea pr ${args.prNumber} --output json --comments`.text() - return result + const result = + await $`tea pr ${args.prNumber} --output json --comments`.text(); + return result; } catch (error: any) { return { error: "Failed to get pull request details", message: error.message, stderr: error.stderr?.toString(), - } + }; } }, -}) \ No newline at end of file +});