diff options
| author | Matt Silverlock <[email protected]> | 2025-12-16 20:14:50 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-16 19:14:50 -0600 |
| commit | c137babea3d05bd9b7c19d1e625978d25cd9c29f (patch) | |
| tree | 36651614003dedd8ce9f63acca67c6b7b0782e4e | |
| parent | db2abc1b2c144f63a205f668bd7267e00829d84a (diff) | |
| download | opencode-c137babea3d05bd9b7c19d1e625978d25cd9c29f.tar.gz opencode-c137babea3d05bd9b7c19d1e625978d25cd9c29f.zip | |
github: add configurable mentions input (#5655)
| -rw-r--r-- | github/action.yml | 5 | ||||
| -rw-r--r-- | packages/opencode/src/cli/cmd/github.ts | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/github/action.yml b/github/action.yml index fe6a32206..2b4553460 100644 --- a/github/action.yml +++ b/github/action.yml @@ -22,6 +22,10 @@ inputs: required: false default: "false" + mentions: + description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'" + required: false + runs: using: "composite" steps: @@ -57,3 +61,4 @@ runs: SHARE: ${{ inputs.share }} PROMPT: ${{ inputs.prompt }} USE_GITHUB_TOKEN: ${{ inputs.use_github_token }} + MENTIONS: ${{ inputs.mentions }} diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts index c7d403395..0d38e503c 100644 --- a/packages/opencode/src/cli/cmd/github.ts +++ b/packages/opencode/src/cli/cmd/github.ts @@ -602,21 +602,26 @@ export const GithubRunCommand = cmd({ } const reviewContext = getReviewCommentContext() + const mentions = (process.env["MENTIONS"] || "/opencode,/oc") + .split(",") + .map((m) => m.trim().toLowerCase()) + .filter(Boolean) let prompt = (() => { const body = payload.comment.body.trim() - if (body === "/opencode" || body === "/oc") { + const bodyLower = body.toLowerCase() + if (mentions.some((m) => bodyLower === m)) { if (reviewContext) { return `Review this code change and suggest improvements for the commented lines:\n\nFile: ${reviewContext.file}\nLines: ${reviewContext.line}\n\n${reviewContext.diffHunk}` } return "Summarize this thread" } - if (body.includes("/opencode") || body.includes("/oc")) { + if (mentions.some((m) => bodyLower.includes(m))) { if (reviewContext) { return `${body}\n\nContext: You are reviewing a comment on file "${reviewContext.file}" at line ${reviewContext.line}.\n\nDiff context:\n${reviewContext.diffHunk}` } return body } - throw new Error("Comments must mention `/opencode` or `/oc`") + throw new Error(`Comments must mention ${mentions.map((m) => "`" + m + "`").join(" or ")}`) })() // Handle images |
