summaryrefslogtreecommitdiffhomepage
path: root/.opencode/tool/github-triage.ts
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-02-17 01:05:56 -0600
committerGitHub <[email protected]>2026-02-17 01:05:56 -0600
commited4e4843c2a65018d6f23f24f86c6a471e391053 (patch)
treedf0919dbc812f1d3b25719c81a593d8ce858d95c /.opencode/tool/github-triage.ts
parenta93a1b93e119a976935e5ab6f214ef7c33d60d45 (diff)
downloadopencode-ed4e4843c2a65018d6f23f24f86c6a471e391053.tar.gz
opencode-ed4e4843c2a65018d6f23f24f86c6a471e391053.zip
ci: update triage workflow (#13944)
Diffstat (limited to '.opencode/tool/github-triage.ts')
-rw-r--r--.opencode/tool/github-triage.ts85
1 files changed, 59 insertions, 26 deletions
diff --git a/.opencode/tool/github-triage.ts b/.opencode/tool/github-triage.ts
index 1e216f1c8..3a70c4e00 100644
--- a/.opencode/tool/github-triage.ts
+++ b/.opencode/tool/github-triage.ts
@@ -1,8 +1,22 @@
/// <reference path="../env.d.ts" />
-// import { Octokit } from "@octokit/rest"
import { tool } from "@opencode-ai/plugin"
import DESCRIPTION from "./github-triage.txt"
+const TEAM = {
+ desktop: ["adamdotdevin", "iamdavidhill", "Brendonovich", "nexxeln"],
+ zen: ["fwang", "MrMushrooooom"],
+ tui: ["thdxr", "kommander", "rekram1-node"],
+ core: ["thdxr", "rekram1-node", "jlongster"],
+ docs: ["R44VC0RP"],
+ windows: ["Hona"],
+} as const
+
+const ASSIGNEES = [...new Set(Object.values(TEAM).flat())]
+
+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")
@@ -29,60 +43,79 @@ export default tool({
description: DESCRIPTION,
args: {
assignee: tool.schema
- .enum(["thdxr", "adamdotdevin", "rekram1-node", "fwang", "jayair", "kommander"])
+ .enum(ASSIGNEES as [string, ...string[]])
.describe("The username of the assignee")
.default("rekram1-node"),
labels: tool.schema
- .array(tool.schema.enum(["nix", "opentui", "perf", "desktop", "zen", "docs", "windows"]))
+ .array(tool.schema.enum(["nix", "opentui", "perf", "web", "desktop", "zen", "docs", "windows", "core"]))
.describe("The labels(s) to add to the issue")
.default([]),
},
async execute(args) {
const issue = getIssueNumber()
- // const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
const owner = "anomalyco"
const repo = "opencode"
const results: string[] = []
+ let labels = [...new Set(args.labels.map((x) => (x === "desktop" ? "web" : x)))]
+ const web = labels.includes("web")
+ const text = `${process.env.ISSUE_TITLE ?? ""}\n${process.env.ISSUE_BODY ?? ""}`.toLowerCase()
+ const zen = /\bzen\b/.test(text) || text.includes("opencode black")
+ const nix = /\bnix(os)?\b/.test(text)
+
+ if (labels.includes("nix") && !nix) {
+ labels = labels.filter((x) => x !== "nix")
+ results.push("Dropped label: nix (issue does not mention nix)")
+ }
+
+ const assignee = nix
+ ? "rekram1-node"
+ : web
+ ? pick(TEAM.desktop)
+ : args.assignee === "jlongster"
+ ? "thdxr"
+ : args.assignee
+
+ if (args.assignee === "jlongster" && assignee === "thdxr") {
+ results.push("Remapped assignee: jlongster -> thdxr (jlongster not assignable yet)")
+ }
+
+ if (labels.includes("zen") && !zen) {
+ throw new Error("Only add the zen label when issue title/body contains 'zen'")
+ }
+
+ if (web && !nix && !(TEAM.desktop as readonly string[]).includes(assignee)) {
+ throw new Error("Web issues must be assigned to adamdotdevin, iamdavidhill, Brendonovich, or nexxeln")
+ }
+
+ if ((TEAM.zen as readonly string[]).includes(assignee) && !labels.includes("zen")) {
+ throw new Error("Only zen issues should be assigned to fwang or MrMushrooooom")
+ }
- if (args.assignee === "adamdotdevin" && !args.labels.includes("desktop")) {
- throw new Error("Only desktop issues should be assigned to adamdotdevin")
+ if (assignee === "Hona" && !labels.includes("windows")) {
+ throw new Error("Only windows issues should be assigned to Hona")
}
- if (args.assignee === "fwang" && !args.labels.includes("zen")) {
- throw new Error("Only zen issues should be assigned to fwang")
+ if (assignee === "R44VC0RP" && !labels.includes("docs")) {
+ throw new Error("Only docs issues should be assigned to R44VC0RP")
}
- if (args.assignee === "kommander" && !args.labels.includes("opentui")) {
+ if (assignee === "kommander" && !labels.includes("opentui")) {
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 githubFetch(`/repos/${owner}/${repo}/issues/${issue}/assignees`, {
method: "POST",
- body: JSON.stringify({ assignees: [args.assignee] }),
+ body: JSON.stringify({ assignees: [assignee] }),
})
- results.push(`Assigned @${args.assignee} to issue #${issue}`)
-
- const labels: string[] = args.labels.map((label) => (label === "desktop" ? "web" : label))
+ results.push(`Assigned @${assignee} to issue #${issue}`)
if (labels.length > 0) {
- // 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(", ")}`)
+ results.push(`Added labels: ${labels.join(", ")}`)
}
return results.join("\n")