From aeccde462e396c6420338ece6841862896a4834c Mon Sep 17 00:00:00 2001 From: kagura-agent Date: Sun, 29 Mar 2026 21:28:27 +0800 Subject: [PATCH] feat(github): add GitHub adapter with 5 public API commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New commands: - github trending — trending repos (by recent stars) - github search — search repositories - github repo — repository details - github user — user profile - github issues — list repository issues All commands use GitHub's public REST API (no auth required, no browser needed). Pure YAML declarative adapters. Tested: all 5 commands return structured data correctly. --- package-lock.json | 4 ++-- src/clis/github/issues.yaml | 45 +++++++++++++++++++++++++++++++++++ src/clis/github/repo.yaml | 36 ++++++++++++++++++++++++++++ src/clis/github/search.yaml | 41 +++++++++++++++++++++++++++++++ src/clis/github/trending.yaml | 41 +++++++++++++++++++++++++++++++ src/clis/github/user.yaml | 32 +++++++++++++++++++++++++ 6 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 src/clis/github/issues.yaml create mode 100644 src/clis/github/repo.yaml create mode 100644 src/clis/github/search.yaml create mode 100644 src/clis/github/trending.yaml create mode 100644 src/clis/github/user.yaml diff --git a/package-lock.json b/package-lock.json index d621228a..50bf9473 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@jackwener/opencli", - "version": "1.5.4", + "version": "1.5.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@jackwener/opencli", - "version": "1.5.4", + "version": "1.5.5", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/src/clis/github/issues.yaml b/src/clis/github/issues.yaml new file mode 100644 index 00000000..c8a2375e --- /dev/null +++ b/src/clis/github/issues.yaml @@ -0,0 +1,45 @@ +site: github +name: issues +description: List issues for a GitHub repository +domain: github.com +strategy: public +browser: false + +args: + owner: + type: string + required: true + description: Repository owner + name: + type: string + required: true + description: Repository name + state: + type: string + default: open + description: "Issue state: open, closed, all" + limit: + type: int + default: 10 + description: Number of issues + +pipeline: + - fetch: + url: "https://api.github.com/repos/${{ args.owner }}/${{ args.name }}/issues?state=${{ args.state }}&per_page=${{ args.limit }}" + headers: + Accept: application/vnd.github.v3+json + User-Agent: opencli + + - filter: "!item.pull_request" + + - map: + number: "#${{ item.number }}" + title: "${{ (item.title || '').substring(0, 60) }}" + author: "${{ item.user.login }}" + labels: "${{ (item.labels || []).map(l => l.name).join(', ') }}" + comments: ${{ item.comments }} + created: "${{ item.created_at?.substring(0, 10) }}" + + - limit: ${{ args.limit }} + +columns: [number, title, author, labels, comments, created] diff --git a/src/clis/github/repo.yaml b/src/clis/github/repo.yaml new file mode 100644 index 00000000..96d3be72 --- /dev/null +++ b/src/clis/github/repo.yaml @@ -0,0 +1,36 @@ +site: github +name: repo +description: GitHub repository details +domain: github.com +strategy: public +browser: false + +args: + owner: + type: string + required: true + description: Repository owner + name: + type: string + required: true + description: Repository name + +pipeline: + - fetch: + url: "https://api.github.com/repos/${{ args.owner }}/${{ args.name }}" + headers: + Accept: application/vnd.github.v3+json + User-Agent: opencli + + - map: + name: "${{ item.full_name }}" + stars: ${{ item.stargazers_count }} + forks: ${{ item.forks_count }} + issues: ${{ item.open_issues_count }} + language: "${{ item.language || '-' }}" + license: "${{ item.license?.spdx_id || '-' }}" + created: "${{ item.created_at?.substring(0, 10) }}" + updated: "${{ item.pushed_at?.substring(0, 10) }}" + description: "${{ (item.description || '').substring(0, 80) }}" + +columns: [name, stars, forks, issues, language, license, description] diff --git a/src/clis/github/search.yaml b/src/clis/github/search.yaml new file mode 100644 index 00000000..31262092 --- /dev/null +++ b/src/clis/github/search.yaml @@ -0,0 +1,41 @@ +site: github +name: search +description: Search GitHub repositories +domain: github.com +strategy: public +browser: false + +args: + query: + type: string + required: true + description: Search query + sort: + type: string + default: stars + description: "Sort by: stars, forks, updated" + limit: + type: int + default: 10 + description: Number of results + +pipeline: + - fetch: + url: "https://api.github.com/search/repositories?q=${{ encodeURIComponent(args.query) }}&sort=${{ args.sort }}&per_page=${{ args.limit }}" + headers: + Accept: application/vnd.github.v3+json + User-Agent: opencli + + - select: items + + - map: + rank: ${{ index + 1 }} + name: "${{ item.full_name }}" + stars: ${{ item.stargazers_count }} + forks: ${{ item.forks_count }} + language: "${{ item.language || '-' }}" + description: "${{ (item.description || '').substring(0, 60) }}" + + - limit: ${{ args.limit }} + +columns: [rank, name, stars, forks, language, description] diff --git a/src/clis/github/trending.yaml b/src/clis/github/trending.yaml new file mode 100644 index 00000000..bfcbb056 --- /dev/null +++ b/src/clis/github/trending.yaml @@ -0,0 +1,41 @@ +site: github +name: trending +description: GitHub trending repositories (by recent stars) +domain: github.com +strategy: public +browser: false + +args: + language: + type: string + default: "" + description: "Filter by language (e.g. typescript, python, rust)" + since: + type: string + default: daily + description: "Time range: daily (7 days), weekly (30 days), monthly (90 days)" + limit: + type: int + default: 10 + description: Number of repositories + +pipeline: + - fetch: + url: "https://api.github.com/search/repositories?q=stars%3A%3E50+created%3A%3E${{ (function(){ const d=new Date(); const days={daily:7,weekly:30,monthly:90}[args.since]||7; d.setDate(d.getDate()-days); return d.toISOString().substring(0,10) })() }}${{ args.language ? '+language%3A'+args.language : '' }}&sort=stars&order=desc&per_page=${{ args.limit }}" + headers: + Accept: application/vnd.github.v3+json + User-Agent: opencli + + - select: items + + - map: + rank: ${{ index + 1 }} + name: "${{ item.full_name }}" + stars: ${{ item.stargazers_count }} + forks: ${{ item.forks_count }} + language: "${{ item.language || '-' }}" + description: "${{ (item.description || '').substring(0, 60) }}" + + - limit: ${{ args.limit }} + +columns: [rank, name, stars, forks, language, description] diff --git a/src/clis/github/user.yaml b/src/clis/github/user.yaml new file mode 100644 index 00000000..2289adb7 --- /dev/null +++ b/src/clis/github/user.yaml @@ -0,0 +1,32 @@ +site: github +name: user +description: GitHub user profile +domain: github.com +strategy: public +browser: false + +args: + username: + type: string + required: true + description: GitHub username + +pipeline: + - fetch: + url: "https://api.github.com/users/${{ args.username }}" + headers: + Accept: application/vnd.github.v3+json + User-Agent: opencli + + - map: + login: "${{ item.login }}" + name: "${{ item.name || '-' }}" + bio: "${{ (item.bio || '').substring(0, 60) }}" + repos: ${{ item.public_repos }} + followers: ${{ item.followers }} + following: ${{ item.following }} + company: "${{ item.company || '-' }}" + location: "${{ item.location || '-' }}" + created: "${{ item.created_at?.substring(0, 10) }}" + +columns: [login, name, repos, followers, following, location]