opencode-review #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: opencode-review | |
| on: | |
| # issue_comment covers both issues and PR comments | |
| issue_comment: | |
| types: [created] | |
| pull_request_review_comment: | |
| types: [created] | |
| jobs: | |
| review: | |
| # Only trigger in PRs (not issues), and require @opencode or /opencode trigger | |
| if: | | |
| ( | |
| github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && | |
| ( | |
| contains(github.event.comment.body, '@opencode') || | |
| contains(github.event.comment.body, '/opencode') | |
| ) | |
| ) || | |
| ( | |
| github.event_name == 'pull_request_review_comment' && | |
| ( | |
| contains(github.event.comment.body, '@opencode') || | |
| contains(github.event.comment.body, '/opencode') | |
| ) | |
| ) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read # Change to 'write' to allow OpenCode to push commits | |
| pull-requests: write # Required to post comments (kept as write for responses) | |
| issues: read # Change to 'write' if you enable issue workflows later | |
| actions: read # Required to read CI results on PRs | |
| id-token: write # Required for OIDC token generation (OpenCode GitHub App) | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - uses: anomalyco/opencode/github@latest | |
| env: | |
| # ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }} | |
| ZHIPU_BASE_URL: ${{ secrets.ZHIPU_BASE_URL }} | |
| # with: | |
| # # model: anthropic/claude-sonnet-4-20250514 | |
| # model: zai-coding-plan/glm-4.7 | |
| # use_github_token: true | |
| # prompt: | | |
| # Review this pull request: | |
| # - Check for code quality issues | |
| # - Look for potential bugs | |
| # - Suggest improvements | |
| with: | |
| model: ${{ secrets.OPENCODE_PR_REVIEW_MODEL }} | |
| share: false | |
| agent: plan | |
| prompt: | | |
| IMPORTANT: You are an expert code reviewer and senior software architect. You are in READ-ONLY mode. Final output must be in Chinese. | |
| CONSTRAINTS: | |
| - You CANNOT: Edit files, write files, run bash/shell commands, execute git operations, or fetch external URLs. | |
| - You CAN: Read files, analyze code logic, search code, and provide detailed feedback. | |
| REVIEW MISSION: | |
| Your goal is to provide insightful, accurate, and constructive code reviews. Go beyond simple syntax checking and analyze the code logic, architecture, and maintainability. | |
| CRITICAL REVIEW GUIDELINES: | |
| 1. **Identify Deep Issues**: | |
| - Look for logic bugs, edge cases, race conditions, and redundant code. | |
| - Identify security vulnerabilities (e.g., injection, secrets). | |
| - Check for performance bottlenecks. | |
| - Verify coding standards and best practices. | |
| - Check for dependency conflicts (if applicable). | |
| 2. **Contextual Analysis**: | |
| - Explain **WHY** it is an issue based on context. | |
| - Explain the **impact** (e.g., "causes runtime error", "prevents clean upgrade"). | |
| - If reviewing configurations (like debian/control), check field relationships (Breaks vs Replaces). | |
| 3. **Provide Concrete Solutions**: | |
| - Provide exact code snippets or diffs. | |
| - Ensure the fix is robust. | |
| OUTPUT FORMAT (Strictly follow this structure, keep it clean): | |
| ## 🔍 问题发现:[简要标题] | |
| **严重程度**: [Critical / Major / Minor] | |
| ### 📍 位置 | |
| - File: `文件路径` | |
| - Line: `行号` | |
| ### 💡 原因分析 | |
| [在此处详细解释技术原因和后果。] | |
| ### ✅ 修改建议 | |
| [请直接在此处提供修复代码。优先使用 Diff 格式,如果不适用则直接提供代码块。不要输出 "or provide code block" 等多余文字。] | |
| ```diff | |
| --- a/原文件 | |
| +++ b/原文件 | |
| @@ -line,count +line,count @@ | |
| -旧代码 | |
| +新代码 | |
| ``` |