Skip to content

Commit c137bab

Browse files
authored
github: add configurable mentions input (anomalyco#5655)
1 parent db2abc1 commit c137bab

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

github/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
required: false
2323
default: "false"
2424

25+
mentions:
26+
description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'"
27+
required: false
28+
2529
runs:
2630
using: "composite"
2731
steps:
@@ -57,3 +61,4 @@ runs:
5761
SHARE: ${{ inputs.share }}
5862
PROMPT: ${{ inputs.prompt }}
5963
USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
64+
MENTIONS: ${{ inputs.mentions }}

packages/opencode/src/cli/cmd/github.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,26 @@ export const GithubRunCommand = cmd({
602602
}
603603

604604
const reviewContext = getReviewCommentContext()
605+
const mentions = (process.env["MENTIONS"] || "/opencode,/oc")
606+
.split(",")
607+
.map((m) => m.trim().toLowerCase())
608+
.filter(Boolean)
605609
let prompt = (() => {
606610
const body = payload.comment.body.trim()
607-
if (body === "/opencode" || body === "/oc") {
611+
const bodyLower = body.toLowerCase()
612+
if (mentions.some((m) => bodyLower === m)) {
608613
if (reviewContext) {
609614
return `Review this code change and suggest improvements for the commented lines:\n\nFile: ${reviewContext.file}\nLines: ${reviewContext.line}\n\n${reviewContext.diffHunk}`
610615
}
611616
return "Summarize this thread"
612617
}
613-
if (body.includes("/opencode") || body.includes("/oc")) {
618+
if (mentions.some((m) => bodyLower.includes(m))) {
614619
if (reviewContext) {
615620
return `${body}\n\nContext: You are reviewing a comment on file "${reviewContext.file}" at line ${reviewContext.line}.\n\nDiff context:\n${reviewContext.diffHunk}`
616621
}
617622
return body
618623
}
619-
throw new Error("Comments must mention `/opencode` or `/oc`")
624+
throw new Error(`Comments must mention ${mentions.map((m) => "`" + m + "`").join(" or ")}`)
620625
})()
621626

622627
// Handle images

0 commit comments

Comments
 (0)