summaryrefslogtreecommitdiffhomepage
path: root/.opencode/tool
diff options
context:
space:
mode:
Diffstat (limited to '.opencode/tool')
-rw-r--r--.opencode/tool/github-triage.ts48
1 files changed, 36 insertions, 12 deletions
diff --git a/.opencode/tool/github-triage.ts b/.opencode/tool/github-triage.ts
index 739135169..a5e6c811d 100644
--- a/.opencode/tool/github-triage.ts
+++ b/.opencode/tool/github-triage.ts
@@ -1,5 +1,5 @@
/// <reference path="../env.d.ts" />
-import { Octokit } from "@octokit/rest"
+// import { Octokit } from "@octokit/rest"
import { tool } from "@opencode-ai/plugin"
import DESCRIPTION from "./github-triage.txt"
@@ -9,6 +9,22 @@ function getIssueNumber(): number {
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,
+ },
+ })
+ if (!response.ok) {
+ throw new Error(`GitHub API error: ${response.status} ${response.statusText}`)
+ }
+ return response.json()
+}
+
export default tool({
description: DESCRIPTION,
args: {
@@ -23,7 +39,7 @@ export default tool({
},
async execute(args) {
const issue = getIssueNumber()
- const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
+ // const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
const owner = "sst"
const repo = "opencode"
@@ -41,22 +57,30 @@ export default tool({
throw new Error("Only opentui issues should be assigned to kommander")
}
- await octokit.rest.issues.addAssignees({
- owner,
- repo,
- issue_number: issue,
- assignees: [args.assignee],
+ // await octokit.rest.issues.addAssignees({
+ // owner,
+ // repo,
+ // issue_number: issue,
+ // assignees: [args.assignee],
+ // })
+ await githubFetch(`/repos/${owner}/${repo}/issues/${issue}/assignees`, {
+ method: "POST",
+ body: JSON.stringify({ assignees: [args.assignee] }),
})
results.push(`Assigned @${args.assignee} to issue #${issue}`)
const labels: string[] = args.labels.map((label) => (label === "desktop" ? "web" : label))
if (labels.length > 0) {
- await octokit.rest.issues.addLabels({
- owner,
- repo,
- issue_number: issue,
- labels,
+ // await octokit.rest.issues.addLabels({
+ // owner,
+ // repo,
+ // issue_number: issue,
+ // labels,
+ // })
+ await githubFetch(`/repos/${owner}/${repo}/issues/${issue}/labels`, {
+ method: "POST",
+ body: JSON.stringify({ labels }),
})
results.push(`Added labels: ${args.labels.join(", ")}`)
}