Skip to content

Commit 4bad6f9

Browse files
committed
tweak: use fetch instead of octokit for now
1 parent d7db57e commit 4bad6f9

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

.opencode/tool/github-triage.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference path="../env.d.ts" />
2-
import { Octokit } from "@octokit/rest"
2+
// import { Octokit } from "@octokit/rest"
33
import { tool } from "@opencode-ai/plugin"
44
import DESCRIPTION from "./github-triage.txt"
55

@@ -9,6 +9,22 @@ function getIssueNumber(): number {
99
return issue
1010
}
1111

12+
async function githubFetch(endpoint: string, options: RequestInit = {}) {
13+
const response = await fetch(`https://api.github.com${endpoint}`, {
14+
...options,
15+
headers: {
16+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
17+
Accept: "application/vnd.github+json",
18+
"Content-Type": "application/json",
19+
...options.headers,
20+
},
21+
})
22+
if (!response.ok) {
23+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`)
24+
}
25+
return response.json()
26+
}
27+
1228
export default tool({
1329
description: DESCRIPTION,
1430
args: {
@@ -23,7 +39,7 @@ export default tool({
2339
},
2440
async execute(args) {
2541
const issue = getIssueNumber()
26-
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
42+
// const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
2743
const owner = "sst"
2844
const repo = "opencode"
2945

@@ -41,22 +57,30 @@ export default tool({
4157
throw new Error("Only opentui issues should be assigned to kommander")
4258
}
4359

44-
await octokit.rest.issues.addAssignees({
45-
owner,
46-
repo,
47-
issue_number: issue,
48-
assignees: [args.assignee],
60+
// await octokit.rest.issues.addAssignees({
61+
// owner,
62+
// repo,
63+
// issue_number: issue,
64+
// assignees: [args.assignee],
65+
// })
66+
await githubFetch(`/repos/${owner}/${repo}/issues/${issue}/assignees`, {
67+
method: "POST",
68+
body: JSON.stringify({ assignees: [args.assignee] }),
4969
})
5070
results.push(`Assigned @${args.assignee} to issue #${issue}`)
5171

5272
const labels: string[] = args.labels.map((label) => (label === "desktop" ? "web" : label))
5373

5474
if (labels.length > 0) {
55-
await octokit.rest.issues.addLabels({
56-
owner,
57-
repo,
58-
issue_number: issue,
59-
labels,
75+
// await octokit.rest.issues.addLabels({
76+
// owner,
77+
// repo,
78+
// issue_number: issue,
79+
// labels,
80+
// })
81+
await githubFetch(`/repos/${owner}/${repo}/issues/${issue}/labels`, {
82+
method: "POST",
83+
body: JSON.stringify({ labels }),
6084
})
6185
results.push(`Added labels: ${args.labels.join(", ")}`)
6286
}

bun.lock

Lines changed: 7 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
},
6565
"dependencies": {
6666
"@aws-sdk/client-s3": "3.933.0",
67-
"@octokit/rest": "22.0.1",
6867
"@opencode-ai/script": "workspace:*",
6968
"@opencode-ai/sdk": "workspace:*",
7069
"typescript": "catalog:"

0 commit comments

Comments
 (0)