import { tool } from "@opencode-ai/plugin"; import { $ } from "bun"; export const labelCreate = tool({ description: "Create a new label with name, color, and optional description", args: { name: tool.schema.string().describe("Label name"), color: tool.schema.string().describe("Hex color code (e.g., #e99695)"), description: tool.schema .string() .optional() .describe("Label description"), }, async execute(args) { try { let cmd = $`tea label create --output json --name ${args.name} --color ${args.color}`; if (args.description) { cmd = cmd`--description ${args.description}`; } const result = await cmd.text(); return result; } catch (error: any) { return { error: "Failed to create label", message: error.message, stderr: error.stderr?.toString(), }; } }, }); export const labelUpdate = tool({ description: "Update an existing label's name, color, or description", args: { labelName: tool.schema.string().describe("Current label name"), newName: tool.schema .string() .optional() .describe("New label name"), newColor: tool.schema .string() .optional() .describe("New hex color code"), newDescription: tool.schema .string() .optional() .describe("New description"), }, async execute(args) { try { let cmd = $`tea label update --output json --name ${args.labelName}`; if (args.newName) { cmd = cmd`--new-name ${args.newName}`; } if (args.newColor) { cmd = cmd`--new-color ${args.newColor}`; } if (args.newDescription) { cmd = cmd`--new-description ${args.newDescription}`; } const result = await cmd.text(); return result; } catch (error: any) { return { error: "Failed to update label", message: error.message, stderr: error.stderr?.toString(), }; } }, }); export const labelDelete = tool({ description: "Delete a label from the repository", args: { labelName: tool.schema.string().describe("Label name to delete"), }, async execute(args) { try { const result = await $`tea label delete --output json --name ${args.labelName}`.text(); return { success: true, message: `Successfully deleted label "${args.labelName}"`, output: result, }; } catch (error: any) { return { error: "Failed to delete label", message: error.message, stderr: error.stderr?.toString(), }; } }, });