diff --git a/.github/prompts/pr_review_rules.md b/.github/prompts/pr_review_rules.md new file mode 100644 index 000000000..56e5a6318 --- /dev/null +++ b/.github/prompts/pr_review_rules.md @@ -0,0 +1,50 @@ +# PR Review Rules for RSSHub + +You are reviewing pull requests for RSSHub. + +Only report **clear and actionable** violations in changed lines/files. Do not report speculative or uncertain issues. + +## Route Metadata and Docs + +1. `example` must start with `/` and be a working RSSHub route path. +2. Route name must not repeat namespace name. +3. In radar rules, `source` must be a relative host/path (no `https://`, no hash/query matching). +4. In radar rules, `target` must match the route path and declared params. +5. Namespace `url` should not include protocol prefix. +6. Use a single category in `categories`. +7. `parameters` keys must match real path parameters. +8. Keep route/docs lists in alphabetical order when touching sorted files. +9. Do not modify default values or working examples unless they are broken. + +## Data Handling and Feed Quality + +10. Use `ctx.cache.tryGet()` for detail fetching in loops; cache processed result instead of raw HTML. +11. `description` should contain article content only; do not duplicate `title`, `author`, `pubDate`, or tags. +12. Extract tags/categories into `category` field. +13. Use `parseDate()` for date fields when source provides time. +14. Do not set fake dates (`new Date()` fallback) when source has no valid time. +15. Keep each item `link` unique and human-readable (not raw API endpoint). +16. Do not trim/truncate title/content manually. + +## API and Requesting + +17. Prefer official API endpoints over scraping when available. +18. Fetch first page only; do not add custom pagination behavior. +19. Use common parameter `limit` instead of custom limit/query filtering. +20. Prefer path parameters over custom query parameters for route config. +21. Use RSSHub built-in UA behavior; avoid unnecessary hardcoded UA/Host unless required. + +## Code Style and Maintainability + +22. Use `camelCase` naming. +23. Use `import type { ... }` for type-only imports. +24. Keep imports sorted. +25. Use `art-template` for custom HTML rendering patterns used by RSSHub. +26. Avoid unnecessary changes outside PR scope. + +## Reporting Format + +- Report only violated rules. +- Each bullet should include: file path, problem, and concrete fix. +- Group repeated issues across files into one concise bullet when possible. +- If no rule is clearly violated, do not comment. diff --git a/.github/prompts/similar_issues.prompt.yml b/.github/prompts/similar_issues.prompt.yml deleted file mode 100644 index c1bf40ea5..000000000 --- a/.github/prompts/similar_issues.prompt.yml +++ /dev/null @@ -1,46 +0,0 @@ -messages: - - role: system - content: |- - You are a GitHub assistant with access to GitHub Model Context Protocol (MCP) - tools in read-only mode. Your task is to search this repository's issues to find - previously filed issues similar to the provided issue title and body. Use the - GitHub tools via MCP to perform the search and retrieve real issue data (do not - fabricate results). Consider semantic similarity across title and body. Exclude - the current issue {{issue_number}}. Return up to 3 of the most similar past issues. If none are - reasonably similar, return an empty list. Output must follow the response schema - exactly and include only data you actually retrieved from GitHub tools. - The current GitHub repository is: "{{repository}}". - - role: user - content: |- - Find similar issues for issue {{issue_number}}: - Title: {{issue_title}} - Body: - {{issue_body}} -model: openai/gpt-4.1-mini -responseFormat: json_schema -jsonSchema: |- - { - "name": "similar_issues_result", - "strict": true, - "schema": { - "type": "object", - "properties": { - "matches": { - "type": "array", - "items": { - "type": "object", - "properties": { - "number": { "type": "integer" }, - "title": { "type": "string" }, - "url": { "type": "string" }, - "similarity_score": { "type": "number", "minimum": 0, "maximum": 1 } - }, - "required": ["number", "title", "url", "similarity_score"], - "additionalProperties": false - } - } - }, - "required": ["matches"], - "additionalProperties": false - } - } diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml new file mode 100644 index 000000000..15209918f --- /dev/null +++ b/.github/workflows/pr-review.yml @@ -0,0 +1,96 @@ +name: pr-review + +on: + pull_request_target: + types: [opened, reopened, synchronize, ready_for_review] + workflow_dispatch: + inputs: + pr_number: + description: Pull request number to review manually + required: true + type: number + +jobs: + review-pr: + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + issues: write + pull-requests: write + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Bun + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 + + - name: Install opencode + run: curl -fsSL https://opencode.ai/install | bash + + - name: Review PR with rules + env: + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} + OPENCODE_PERMISSION: | + { + "bash": { + "*": "deny", + "gh auth*": "allow", + "gh pr*": "allow", + "gh api*": "allow" + }, + "webfetch": "deny" + } + run: | + if [ -z "$PR_NUMBER" ]; then + echo "pr_number is required" + exit 1 + fi + + RULES=$(cat .github/prompts/pr_review_rules.md) + + opencode run -m ${{ vars.OPENCODE_MODEL }} "A pull request has been created or updated in this repository. + + Pull request number: + $PR_NUMBER + + Repository: + $GITHUB_REPOSITORY + + Your task: + 1. Use GitHub CLI commands to inspect this PR's metadata and code changes. + 2. Review only based on the following rules. + 3. Report only clear and actionable violations from changed files. + 4. If no clear violations are found, do not comment. + + Review rules: + $RULES + + Required behavior: + - Keep feedback concise and grouped by rule. + - Include file path and a concrete fix suggestion for each issue. + - Ignore uncertain or low-confidence findings. + - Avoid duplicate comments. + + Comment protocol: + - Use marker: + - Check existing comments in issue comments for this marker. + - If a marker comment exists, update it with latest findings. + - Otherwise create a new PR comment. + - If there are no findings and marker comment exists, edit marker comment to a short pass status. + + Suggested comment format: + + ## Auto Review + - [Rule] file: issue + suggestion + + For no findings: + + ## Auto Review + No clear rule violations found in the current diff. + + Use only gh commands and repository data."