Skip to content

Commit bfea604

Browse files
authored
Merge pull request #43 from alexyaroshuk/add-pr-triage
adjust tool file
2 parents 3983d35 + 7add749 commit bfea604

4 files changed

Lines changed: 33 additions & 93 deletions

File tree

.github/workflows/pr-triage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: pr-triage
22

33
on:
44
pull_request_target:
5-
types: [opened, edited, synchronize]
5+
types: [opened]
66

77
jobs:
88
triage-pr:

.github/workflows/test-pr-triage.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.opencode/agent/pr-triage.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,56 @@ tools:
1010

1111
You are a triage agent responsible for triaging pull requests.
1212

13-
Use your github-pr-triage tool to triage issues and PRs.
13+
Use your github-pr-triage tool to triage pull requests.
1414

1515
## Labels
1616

1717
### windows
1818

19-
Use for any issue or PR that mentions Windows (the OS). Be sure they are saying that they are on Windows.
19+
Use for any pull request that mentions Windows (the OS). Be sure they are saying that they are on Windows.
2020

2121
- Use if they mention WSL too
2222

2323
#### perf
2424

25-
Performance-related issues:
25+
Performance-related pull requests:
2626

2727
- Slow performance
2828
- High RAM usage
2929
- High CPU usage
3030

31-
**Only** add if it's likely a RAM or CPU issue. **Do not** add for LLM slowness.
31+
**Only** add if it's likely a RAM or CPU pull requests. **Do not** add for LLM slowness.
3232

3333
#### desktop
3434

35-
Desktop app issues:
35+
Desktop app pull requests:
3636

3737
- `opencode web` command
3838
- The desktop app itself
3939

40-
**Only** add if it's specifically about the Desktop application or `opencode web` view. **Do not** add for terminal, TUI, or general opencode issues.
40+
**Only** add if it's specifically about the Desktop application or `opencode web` view. **Do not** add for terminal, TUI, or general opencode pull requests.
4141

4242
#### nix
4343

44-
**Only** add if the issue or PR explicitly mentions nix.
44+
**Only** add if the pull request explicitly mentions nix.
4545

4646
#### zen
4747

48-
**Only** add if the issue or PR mentions "zen" or "opencode zen" or "opencode black".
48+
**Only** add if the pull request mentions "zen" or "opencode zen" or "opencode black".
4949

50-
If the issue doesn't have "zen" or "opencode black" in it then don't add zen label
50+
If the pull request doesn't have "zen" or "opencode black" in it then don't add zen label
5151

5252
#### docs
5353

54-
Add if the issue or PR requests or contains documentation updates.
54+
Add if the pull request requests or contains documentation updates.
5555

5656
#### opentui
5757

58-
TUI issues potentially caused by our underlying TUI library:
58+
Add if the pull requests addresses TUI issues potentially caused by our underlying TUI library:
5959

6060
- Keybindings not working
6161
- Scroll speed issues (too fast/slow/laggy)
6262
- Screen flickering
6363
- Crashes with opentui in the log
6464

65-
**Do not** add for general TUI bugs.
66-
67-
<!-- When assigning to people here are the following rules:
68-
69-
adamdotdev:
70-
ONLY assign adam if the issue will have the "desktop" label.
71-
72-
fwang:
73-
ONLY assign fwang if the issue will have the "zen" label.
74-
75-
jayair:
76-
ONLY assign jayair if the issue will have the "docs" label.
77-
78-
In all other cases use best judgment. Avoid assigning to kommander needlessly, when in doubt assign to rekram1-node. -->
65+
**Do not** add for general TUI bugfixes.

.opencode/tool/github-pr-triage.ts

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function getPRNumber(): number {
99
}
1010

1111
async function githubFetch(endpoint: string, options: RequestInit = {}) {
12-
const url = `https://api.github.com${endpoint}`
13-
const response = await fetch(url, {
12+
const response = await fetch(`https://api.github.com${endpoint}`, {
1413
...options,
1514
headers: {
1615
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
@@ -20,8 +19,7 @@ async function githubFetch(endpoint: string, options: RequestInit = {}) {
2019
},
2120
})
2221
if (!response.ok) {
23-
const error = await response.text()
24-
throw new Error(`GitHub API ${response.status}: ${error}`)
22+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`)
2523
}
2624
return response.json()
2725
}
@@ -41,43 +39,34 @@ async function ensureLabelExists(owner: string, repo: string, label: string) {
4139
}
4240
}
4341

44-
function getRepoInfo(): { owner: string; repo: string } {
45-
const repoFull = process.env.GITHUB_REPOSITORY ?? ""
46-
const [owner, repo] = repoFull.split("/")
47-
return { owner: owner ?? "anomalyco", repo: repo ?? "opencode" }
48-
}
49-
5042
export default tool({
5143
description: DESCRIPTION,
5244
args: {
53-
action: tool.schema.string().describe("Action to perform").optional(),
54-
label: tool.schema.string().describe("Single label to add").optional(),
55-
labels: tool.schema.array(tool.schema.string()).describe("Labels to add").optional(),
56-
reason: tool.schema.string().describe("Reason for the label").optional(),
45+
labels: tool.schema
46+
.array(tool.schema.enum(["nix", "opentui", "perf", "desktop", "zen", "docs", "windows"]))
47+
.describe("The label(s) to add to the PR")
48+
.default([]),
5749
},
5850
async execute(args) {
5951
const pr = getPRNumber()
60-
const { owner, repo } = getRepoInfo()
52+
const owner = "alexyaroshuk"
53+
const repo = "opencode"
6154

62-
let labels: string[] = []
55+
const results: string[] = []
6356

64-
if (args.label) {
65-
labels = [args.label]
66-
} else if (args.labels) {
67-
labels = args.labels
68-
} else {
69-
labels = ["zen"]
70-
}
57+
const labels: string[] = args.labels
7158

72-
for (const label of labels) {
73-
await ensureLabelExists(owner, repo, label)
59+
if (labels.length > 0) {
60+
for (const label of labels) {
61+
await ensureLabelExists(owner, repo, label)
62+
}
63+
await githubFetch(`/repos/${owner}/${repo}/issues/${pr}/labels`, {
64+
method: "POST",
65+
body: JSON.stringify({ labels }),
66+
})
67+
results.push(`Added labels: ${args.labels.join(", ")}`)
7468
}
7569

76-
await githubFetch(`/repos/${owner}/${repo}/issues/${pr}/labels`, {
77-
method: "POST",
78-
body: JSON.stringify({ labels }),
79-
})
80-
81-
return `Added labels: ${labels.join(", ")}`
70+
return results.join("\n")
8271
},
8372
})

0 commit comments

Comments
 (0)