Files
jackwener__opencli/docs/adapters/browser/github-trending.md
leo1in88 7af50abd04 feat(github): add github trending adapter (#1953)
* feat(github): add `github trending` adapter

Add a PUBLIC adapter that lists repositories from
https://github.com/trending — the trending view is a public HTML page with
no official REST API, so the data was previously unreachable through opencli.

The adapter fetches the page server-side (no browser, no auth) and parses
each repo's full name, description, primary language, total stars, forks,
and stars gained in the period.

Flags:
- `--since`    daily | weekly | monthly (default daily)
- `--language` filter by language slug, e.g. python, rust, "c++"
- `--limit`    1..25 (GitHub lists at most 25)

Typed errors: ArgumentError for bad --since / --limit, CommandExecutionError
on request/HTTP failure, EmptyResultError when the page yields no repos.

Tests cover parsing (stars/forks/language/description/url, missing language),
limit truncation, language+since URL building, argument validation, the
empty-result path, and non-ok HTTP.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(github-trending): rename to standalone `github-trending repos`

Move the trending scraper out of the `github` site namespace into a
dedicated `github-trending` adapter to avoid confusion with the bundled
`gh` external CLI. Command is now `opencli github-trending repos`
(site=github-trending, name=repos), leaving room for a future
`developers` subcommand. The `github` site retains only login/whoami.

Regenerated cli-manifest.json; 8 fixture tests + typecheck pass.

* fix(github-trending): fail closed on parser drift

---------

Co-authored-by: minh <claude@ttfy.cc>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-06-22 21:27:57 +08:00

41 lines
1.3 KiB
Markdown

# GitHub Trending
**Mode**: 🌐 Public · **Domain**: `github.com`
## Commands
| Command | Description |
|---------|-------------|
| `opencli github-trending repos` | List repositories from GitHub Trending |
## Usage Examples
```bash
# Daily trending repositories
opencli github-trending repos --limit 10
# Weekly Rust trending repositories
opencli github-trending repos --language rust --since weekly --limit 10
# Language slugs are URL-encoded before calling github.com/trending
opencli github-trending repos --language "c++" --since monthly -f json
```
## Arguments
| Argument | Description |
|----------|-------------|
| `--since` | Time range: `daily`, `weekly`, or `monthly` (default: `daily`) |
| `--language` | Optional GitHub Trending language slug, for example `python`, `rust`, or `c++` |
| `--limit` | Number of repositories to return, 1-25 |
## Output Columns
`rank`, `repo`, `description`, `language`, `stars`, `forks`, `starsSince`, `url`
## Notes
- This command reads the public server-rendered `https://github.com/trending` page. GitHub does not expose an official REST endpoint for Trending.
- It does not use the logged-in GitHub browser session and does not call `gh`.
- Parser drift is treated as a command execution error. A true empty result requires GitHub's explicit empty-state page.