GeezerVison is showing github.com — github: add configurable mentions input (#5655) · maximkr/opencode@c137bab
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/opencode/src/cli/cmd
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: github/action.yml +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,10 @@ inputs: |
22 | 22 | required: false |
23 | 23 | default: "false" |
24 | 24 |
|
| 25 | + mentions: |
| 26 | + description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'" |
| 27 | + required: false |
| 28 | + |
25 | 29 | runs: |
26 | 30 | using: "composite" |
27 | 31 | steps: |
|
57 | 61 | SHARE: ${{ inputs.share }} |
58 | 62 | PROMPT: ${{ inputs.prompt }} |
59 | 63 | USE_GITHUB_TOKEN: ${{ inputs.use_github_token }} |
| 64 | + MENTIONS: ${{ inputs.mentions }} |
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/github.ts +8-3Lines changed: 8 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -602,21 +602,26 @@ export const GithubRunCommand = cmd({ |
602 | 602 | } |
603 | 603 |
|
604 | 604 | const reviewContext = getReviewCommentContext() |
| 605 | + const mentions = (process.env["MENTIONS"] || "/opencode,/oc") |
| 606 | + .split(",") |
| 607 | + .map((m) => m.trim().toLowerCase()) |
| 608 | + .filter(Boolean) |
605 | 609 | let prompt = (() => { |
606 | 610 | const body = payload.comment.body.trim() |
607 | | - if (body === "/opencode" || body === "/oc") { |
| 611 | + const bodyLower = body.toLowerCase() |
| 612 | + if (mentions.some((m) => bodyLower === m)) { |
608 | 613 | if (reviewContext) { |
609 | 614 | return `Review this code change and suggest improvements for the commented lines:\n\nFile: ${reviewContext.file}\nLines: ${reviewContext.line}\n\n${reviewContext.diffHunk}` |
610 | 615 | } |
611 | 616 | return "Summarize this thread" |
612 | 617 | } |
613 | | - if (body.includes("/opencode") || body.includes("/oc")) { |
| 618 | + if (mentions.some((m) => bodyLower.includes(m))) { |
614 | 619 | if (reviewContext) { |
615 | 620 | return `${body}\n\nContext: You are reviewing a comment on file "${reviewContext.file}" at line ${reviewContext.line}.\n\nDiff context:\n${reviewContext.diffHunk}` |
616 | 621 | } |
617 | 622 | return body |
618 | 623 | } |
619 | | - throw new Error("Comments must mention `/opencode` or `/oc`") |
| 624 | + throw new Error(`Comments must mention ${mentions.map((m) => "`" + m + "`").join(" or ")}`) |
620 | 625 | })() |
621 | 626 |
|
622 | 627 | // Handle images |
|