Skip to content

feat(github): add github trending adapter#1953

Open
leo1in88 wants to merge 1 commit into
jackwener:mainfrom
leo1in88:feat/github-trending
Open

feat(github): add github trending adapter#1953
leo1in88 wants to merge 1 commit into
jackwener:mainfrom
leo1in88:feat/github-trending

Conversation

@leo1in88

Copy link
Copy Markdown

What & why

GitHub's Trending view (https://github.com/trending) has no official REST API — it's a server-rendered HTML page — so opencli had no way to surface it. This adds a github trending adapter that lists trending repositories.

Strategy

PUBLIC (browser: false). The page is public HTML, no login or token. The adapter fetches it server-side with fetch and parses each article.Box-row for: full name, description, primary language, total stars, forks, and stars gained in the period. No third-party deps (plain regex parsing).

Flags

flag values default
--since daily / weekly / monthly daily
--language language slug (python, rust, "c++", …) (all)
--limit 1..25 (GitHub lists at most 25) 25

Columns

rank, repo, description, language, stars, forks, starsSince, url

Typed errors

  • ArgumentError — invalid --since or out-of-range --limit
  • CommandExecutionError — network failure / non-2xx HTTP
  • EmptyResultError — page returned no repositories

Usage

opencli github trending
opencli github trending --language rust --since weekly --limit 10 -f json

Test plan

  • npx vitest run --project adapter clis/github/trending.test.js8 passing: parsing (stars/forks/language/description/url + missing language → null), --limit truncation, language+since URL building (/trending/rust?since=weekly), argument validation, empty-result path, non-ok HTTP.
  • npx tsc --noEmit → clean.
  • cli-manifest.json regenerated via npm run build-manifest (adds the new command).
  • Manually verified live against https://github.com/trending (daily + weekly/language filters) — values match the rendered page.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant