From d629c66a42faaa920a8658bb401fde2896e4653f Mon Sep 17 00:00:00 2001 From: TonyRL Date: Fri, 4 Sep 2026 03:06:11 +0800 Subject: [PATCH] chore: update prompts --- .github/prompts/pr_review_rules.md | 1 - .github/workflows/pr-review.yml | 3 +- AGENTS.md | 102 +++++++++++++---------------- 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/.github/prompts/pr_review_rules.md b/.github/prompts/pr_review_rules.md index a162ccec99..433fb1b1f6 100644 --- a/.github/prompts/pr_review_rules.md +++ b/.github/prompts/pr_review_rules.md @@ -47,4 +47,3 @@ Only report **clear and actionable** violations in changed lines/files. Do not r - 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/workflows/pr-review.yml b/.github/workflows/pr-review.yml index a694692e25..ab16fe3230 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -131,7 +131,6 @@ jobs: 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 @@ -147,7 +146,7 @@ jobs: - 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. + - If there are no findings: when a marker comment exists, edit it to the short pass status below; when none exists, do not comment. gh command reference (PR_NUMBER and GITHUB_REPOSITORY are available as env vars): - Create a new PR comment: diff --git a/AGENTS.md b/AGENTS.md index 4576664659..0cc2d2a5a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,124 +4,114 @@ 1. **Example Format**: The `example` field must start with `/` and be a working RSSHub route path (e.g., `/example/route`), not a full URL or source website URL. -2. **Route Name**: Do NOT repeat the namespace name in the route name. The namespace is already defined in `namespace.ts`. +2. **Route Name**: Do not repeat the namespace name in the route name. The namespace is already defined in `namespace.ts`. 3. **Radar Source Format**: Use relative paths without `https://` prefix in `radar[]. source`. Example: `source: ['www.example.com/path']` instead of `source: ['https://www.example.com/path']`. 4. **Radar Target**: The `radar[].target` must match the route path. If the source URL does not contain a path parameter, do not include it in the target. -5. **Namespace URL**: In `namespace.ts`, the `url` field should NOT include the `https://` protocol prefix. +5. **Namespace URL**: In `namespace.ts`, the `url` field should not include the `https://` protocol prefix. -6. **Single Category**: Provide only ONE category in the `categories` array, not multiple. +6. **Single Category**: Provide only one category in the `categories` array, not multiple. -7. **Unnecessary Files**: Do NOT create separate `README.md` or `radar.ts` files. Put descriptions in `Route['description']` and radar rules in `Route['radar']`. +7. **Unnecessary Files**: Do not create separate `README.md` or `radar.ts` files. Put descriptions in `Route['description']` and radar rules in `Route['radar']`. -8. **Legacy Router**: Do NOT add routes to `lib/router.js` - this file is deprecated. +8. **Features Accuracy**: Set `requirePuppeteer: true` only if your route actually uses Puppeteer. Do not mismatch feature flags. -9. **Features Accuracy**: Set `requirePuppeteer: true` only if your route actually uses Puppeteer. Do not mismatch feature flags. - -10. **Maintainer GitHub ID**: The `maintainers` field must contain valid GitHub usernames. Verify that the username exists before adding it. +9. **Maintainer GitHub ID**: The `maintainers` field must contain valid GitHub usernames. Verify that the username exists before adding it. ### Code Style -11. **Naming Convention**: Use `camelCase` for variable names in JavaScript/TypeScript. Avoid `snake_case` (e.g., use `videoUrl` instead of `video_url`). +10. **Naming Convention**: Use `camelCase` for variable names in JavaScript/TypeScript. Avoid `snake_case` (e.g., use `videoUrl` instead of `video_url`). -12. **Type Imports**: Use `import type { ... }` for type-only imports instead of `import { ... }`. +11. **Import Sorting**: Keep imports sorted. Run autofix if linter reports import order issues. -13. **Import Sorting**: Keep imports sorted. Run autofix if linter reports import order issues. +12. **Avoid Loading HTML Twice**: Do not call `load()` from cheerio multiple times on the same content. Reuse the initial `$` object. -14. **Unnecessary Template Literals**: Do not use template literals when simple strings suffice (e.g., use `'plain string'` instead of `` `plain string` ``). +13. **Async/Await in Close**: When closing Puppeteer pages/browsers, use `await page.close()` and `await browser.close()` instead of non-awaited calls. -15. **Avoid Loading HTML Twice**: Do not call `load()` from cheerio multiple times on the same content. Reuse the initial `$` object. +14. **No Explicit Null**: No need to explicitly set a property to `null` if it does not exist - just omit it. -16. **Async/Await in Close**: When closing Puppeteer pages/browsers, use `await page.close()` and `await browser.close()` instead of non-awaited calls. +15. **Valid Item Properties**: Only use properties defined in [lib/types.ts](https://github.com/DIYgod/RSSHub/blob/master/lib/types.ts). Custom properties like `avatar`, `bio` will be ignored by RSSHub. -17. **No Explicit Null**: No need to explicitly set a property to `null` if it does not exist - just omit it. - -18. **Valid Item Properties**: Only use properties defined in [lib/types. ts](https://github.com/DIYgod/RSSHub/blob/master/lib/types.ts). Custom properties like `avatar`, `bio` will be ignored by RSSHub. - -19. **String Methods**: Use `startsWith()` instead of `includes()` when checking if a string begins with a specific prefix. - -20. **Simplify Code**: Combine multiple conditional assignments into single expressions using `||` or `??` operators when appropriate. +16. **String Methods**: Use `startsWith()` instead of `includes()` when checking if a string begins with a specific prefix. ### Data Handling -21. **Use Cache**: Always [cache](https://docs.rsshub.app/joinus/advanced/use-cache) the returned results when fetching article details in a loop using `cache.tryGet()`. +17. **Use Cache**: Always [cache](https://docs.rsshub.app/joinus/advanced/use-cache) the returned results when fetching article details in a loop using `cache.tryGet()`. -22. **Description Content**: The `description` field should contain ONLY the main article content. Do NOT include `title`, `author`, `pubDate`, or tags in `description` - they have their own dedicated fields. +18. **Description Content**: The `description` field should contain ONLY the main article content. Do not include `title`, `author`, `pubDate`, or tags in `description` - they have their own dedicated fields. -23. **Category Field**: Extract tags/categories from articles and place them in the `category` field, not in `description`. +19. **Category Field**: Extract tags/categories from articles and place them in the `category` field, not in `description`. -24. **pubDate Field**: Always include `pubDate` when the source provides date/time information. Use the `parseDate` utility function. +20. **pubDate Field**: Always include `pubDate` when the source provides date/time information. Use the `parseDate` utility function. -25. **No Fake Dates**: Do NOT use `new Date()` as a fallback for `pubDate`. If no date is available, leave it undefined. See [No Date documentation](https://docs.rsshub.app/joinus/advanced/pub-date#no-date). +21. **No Fake Dates**: Do not use `new Date()` as a fallback for `pubDate`. If no date is available, leave it undefined. See [No Date documentation](https://docs.rsshub.app/joinus/advanced/pub-date#no-date). -26. **No Title Trimming**: Do not manually trim or truncate titles. RSSHub core handles title processing automatically. +22. **No Title Trimming**: Do not manually trim or truncate titles. RSSHub core handles title processing automatically. -27. **Unique Links**: Ensure each item's `link` is unique as it will be used as `guid`. Avoid fallback URLs that could cause duplicate `guid` values. +23. **Unique Links**: Ensure each item's `link` is unique as it will be used as `guid`. Avoid fallback URLs that could cause duplicate `guid` values. -28. **Human-Readable Links**: The feed `link` field should point to a human-readable webpage URL, NOT an API endpoint URL. +24. **Human-Readable Links**: The feed `link` field should point to a human-readable webpage URL, not an API endpoint URL. ### API and Data Fetching -29. **Prefer APIs Over Scraping**: When the target website has an API (often found by scrolling pages or checking network requests), use the API endpoint instead of HTML scraping. +25. **Prefer APIs Over Scraping**: When the target website has an API (often found by scrolling pages or checking network requests), use the API endpoint instead of HTML scraping. -30. **JSON Parsing**: When using `ofetch`, `JSON.parse` is automatically applied. Do not manually decode JSON escape sequences like `\u003C`. +26. **JSON Parsing**: When using `ofetch`, `JSON.parse` is automatically applied. Do not manually decode JSON escape sequences like `\u003C`. -31. **No Page Turning**: RSS feeds should only request the first page of content. Do not implement pagination parameters for users. +27. **No Page Turning**: RSS feeds should only request the first page of content. Do not implement pagination parameters for users. -32. **Use Common Parameters**: Use RSSHub's built-in common parameters like [`limit`](https://docs.rsshub.app/guide/parameters#limit-entries) instead of implementing custom query parameters for limiting entries. +28. **Use Common Parameters**: Use RSSHub's built-in common parameters like [`limit`](https://docs.rsshub.app/guide/parameters#limit-entries) instead of implementing custom query parameters for limiting entries. -33. **No Custom Query Parameters**: Avoid using querystring parameters for route configuration. Use path parameters (`:param`) instead. +29. **No Custom Query Parameters**: Avoid using querystring parameters for route configuration. Use path parameters (`:param`) instead. -34. **No Custom Filtering**: Do not implement custom tag/category filtering in routes. Users can apply filtering using [common parameters](https://docs.rsshub.app/guide/parameters). +30. **No Custom Filtering**: Do not implement custom tag/category filtering in routes. Users can apply filtering using [common parameters](https://docs.rsshub.app/guide/parameters). -35. **Avoid Dynamic Hashes**: If an API requires a hash that changes across builds, extract it dynamically from the webpage rather than hardcoding it. - -36. **User-Agent**: Use RSSHub's built-in [User-Agent](https://github.com/DIYgod/RSSHub/blob/master/lib/config.ts#L494) (`config.trueUA`) when making requests that need realistic browser headers. +31. **Avoid Dynamic Hashes**: If an API requires a hash that changes across builds, extract it dynamically from the webpage rather than hardcoding it. ### Media and Enclosures -37. **Valid MIME Types**: The `enclosure_type` must be a valid MIME type as defined in RFC specifications. For example, `video/youtube` is NOT valid - use actual video file URLs with proper types like `video/mp4`. +32. **Valid MIME Types**: The `enclosure_type` must be a valid MIME type as defined in RFC specifications. For example, `video/youtube` is not valid - use actual video file URLs with proper types like `video/mp4`. -38. **Direct Media URLs**: `enclosure_url` must point directly to downloadable media files (e.g., `.mp4`, `.mp3`), not to web pages containing media. +33. **Direct Media URLs**: `enclosure_url` must point directly to downloadable media files (e.g., `.mp4`, `.mp3`), not to web pages containing media. -39. **Video Poster**: Use the HTML5 `