22486c90eb
Replace legacy "opencode" references with "kilo" in CLI output, API metadata, SDK error messages, and documentation. Add automatic labels to GitHub issue templates, expand triage agent with jetbrains and extension teams, and update the github-triage tool to target the Kilo-Org/kilocode repository.
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
/// <reference path="../env.d.ts" />
|
|
import { tool } from "@kilocode/plugin"
|
|
|
|
// kilocode_change start
|
|
const TEAM = {
|
|
tui: ["catrielmuller"],
|
|
desktop_web: ["markijbema"],
|
|
core: ["markijbema", "marius-kilocode", "catrielmuller", "chrarnoldus", "imanolmzd-svg"],
|
|
jetbrains: ["kirillk"],
|
|
inference: ["chrarnoldus", "markijbema"],
|
|
windows: ["catrielmuller"],
|
|
} as const
|
|
// kilocode_change end
|
|
|
|
function pick<T>(items: readonly T[]) {
|
|
return items[Math.floor(Math.random() * items.length)]!
|
|
}
|
|
|
|
function getIssueNumber(): number {
|
|
const issue = parseInt(process.env.ISSUE_NUMBER ?? "", 10)
|
|
if (!issue) throw new Error("ISSUE_NUMBER env var not set")
|
|
return issue
|
|
}
|
|
|
|
async function githubFetch(endpoint: string, options: RequestInit = {}) {
|
|
const response = await fetch(`https://api.github.com${endpoint}`, {
|
|
...options,
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
|
|
Accept: "application/vnd.github+json",
|
|
"Content-Type": "application/json",
|
|
...(options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers),
|
|
},
|
|
})
|
|
if (!response.ok) {
|
|
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`)
|
|
}
|
|
return response.json()
|
|
}
|
|
|
|
export default tool({
|
|
description: `Use this tool to assign a GitHub issue.
|
|
|
|
Provide the team that should own the issue. This tool picks a random assignee from that team and does not apply labels.`,
|
|
args: {
|
|
team: tool.schema
|
|
.enum(Object.keys(TEAM) as [keyof typeof TEAM, ...(keyof typeof TEAM)[]])
|
|
.describe("The owning team"),
|
|
},
|
|
async execute(args) {
|
|
const issue = getIssueNumber()
|
|
// kilocode_change start
|
|
const owner = "Kilo-Org"
|
|
const repo = "kilocode"
|
|
// kilocode_change end
|
|
const assignee = pick(TEAM[args.team])
|
|
|
|
await githubFetch(`/repos/${owner}/${repo}/issues/${issue}/assignees`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ assignees: [assignee] }),
|
|
})
|
|
|
|
return `Assigned @${assignee} from ${args.team} to issue #${issue}`
|
|
},
|
|
})
|