feat: add tea-milestone.ts tool for milestone management (milestoneList, milestoneCreate)

This commit is contained in:
2026-05-03 16:35:24 +02:00
parent 960457275e
commit 1a900037ff

View File

@@ -0,0 +1,52 @@
import { tool } from "@opencode-ai/plugin"
import { $ } from "bun"
export const milestoneList = tool({
description: "List milestones with their status and progress",
args: {
state: tool.schema.enum(["open", "closed", "all"]).default("open").describe("Filter by state"),
},
async execute(args, context) {
try {
const result = await $`tea milestone list --output json --state ${args.state}`.text()
return JSON.parse(result)
} catch (error: any) {
return {
error: "Failed to list milestones",
message: error.message,
stderr: error.stderr?.toString(),
}
}
},
})
export const milestoneCreate = tool({
description: "Create a new milestone with title, description, and optional due date",
args: {
title: tool.schema.string().describe("Milestone title"),
description: tool.schema.string().optional().describe("Milestone description"),
dueDate: tool.schema.string().optional().describe("Due date (format: YYYY-MM-DD)"),
},
async execute(args, context) {
try {
let cmd = $`tea milestone create --output json --title ${args.title}`
if (args.description) {
cmd = cmd`--description ${args.description}`
}
if (args.dueDate) {
cmd = cmd`--due-date ${args.dueDate}`
}
const result = await cmd.text()
return JSON.parse(result)
} catch (error: any) {
return {
error: "Failed to create milestone",
message: error.message,
stderr: error.stderr?.toString(),
}
}
},
})