11/// <reference path="../env.d.ts" />
2- import { Octokit } from "@octokit/rest"
2+ // import { Octokit } from "@octokit/rest"
33import { tool } from "@opencode-ai/plugin"
44import 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+
1228export 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 }
0 commit comments