import { $ } from "bun" import type { Info } from "@opencode/plugin/promise/tool" const teaPrCreate: Info = { name: "tea-pr-create", description: "Create a pull request in the repository using tea CLI", input: { type: "object", properties: { title: { type: "string", description: "PR title" }, head: { type: "string", description: "Branch name of the PR source (defaults to current branch)" }, base: { type: "string", description: "Branch name of the PR target (defaults to repository default branch)" }, description: { type: "string", description: "PR description (supports markdown)" }, assignees: { type: "string", description: "Comma-separated list of usernames to assign" }, labels: { type: "string", description: "Comma-separated list of labels to assign" }, }, required: ["title"], additionalProperties: false, }, async execute(input) { const { title, head, base, description, assignees, labels } = input as { title: string head?: string base?: string description?: string assignees?: string labels?: string } let cmd = [`tea`, `pulls`, `create`, `-t`, title] if (head) cmd = [...cmd, `--head`, head] if (base) cmd = [...cmd, `-b`, base] if (description) cmd = [...cmd, `-d`, description] if (assignees) cmd = [...cmd, `-a`, assignees] if (labels) cmd = [...cmd, `-L`, labels] const result = await $`${cmd}`.text() return { content: result.trim() } }, } export default teaPrCreate