demo-3-repo-pulse
Demo skill that pulls live GitHub API data for a repo, analyses a full year of weekly commit activity and top contributors, and renders a single-file dashboard.html with stat tiles and inline SVG charts — no chart library.
decodingai-magazine · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add decodingai-magazine/building-a-coding-agent-from-scratch-course --skill demo-3-repo-pulse技能说明
name: demo-3-repo-pulse description: Demo skill that pulls live GitHub API data for a repo, analyses a full year of weekly commit activity and top contributors, and renders a single-file dashboard.html with stat tiles and inline SVG charts — no chart library.
Build a repo pulse dashboard from live data: probe the GitHub API, pull a repository's last
52 weeks of activity, analyse it, and render everything into one self-contained
.decode/outputs/dashboard.html the human can open in a browser. All files this demo produces
live under .decode/outputs/ (unless the human named a different path).
Default target repository: pydantic/pydantic-ai. If the human named a different owner/repo,
use that instead.
1. Probe the data source
Use web_fetch to look at the live API and learn the exact field names before writing any code:
https://api.github.com/repos/pydantic/pydantic-ai— notestargazers_count,forks_count,open_issues_count,description.
That one probe is enough — do not fetch the big endpoints with web_fetch; the analysis script
will pull those.
2. Write the analysis script
Write .decode/outputs/pulse.py and run it with the one dependency brought in just for the run
(do NOT add project dependencies):
uv run --with requests python .decode/outputs/pulse.py
The script must:
- GET these three endpoints (plain
requests, no auth token needed):https://api.github.com/repos/{owner}/{repo}— the headline stats.https://api.github.com/repos/{owner}/{repo}/stats/commit_activity— the last 52 weeks of commit counts, one entry per week (totalcommits + a Unixweektimestamp). The whole year arrives in this ONE request — never page through/commitsfor it.https://api.github.com/repos/{owner}/{repo}/contributors?per_page=10— top contributors with their commit counts.
- The stats endpoint answers 202 while GitHub computes the data: retry a few times with a short sleep until it answers 200 with the 52-entry list.
- Aggregate: commits per week across the 52 weeks (label each week with the ISO date of its
weektimestamp), the busiest week of the year, and the top-10 contributor leaderboard. - If the API answers 403 (rate limit), say so plainly; if
GITHUB_TOKENis set in the environment, send it as aBearerheader.
3. Render the dashboard — charts as inline SVG
Have the script generate .decode/outputs/dashboard.html — one file, zero external requests,
no chart library. Draw both charts as inline <svg> elements built with Python string
formatting (no image files, no JavaScript):
- A header with the repo name and description.
- Four stat tiles: ⭐ stars, 🍴 forks, 🐛 open issues, 👥 contributors shown.
- Commits per week — an SVG bar chart: one
<rect>per week (52 bars), heights scaled to the busiest week, a handful of month labels along the x-axis, and a<title>tooltip per bar (YYYY-MM-DD — N commits). - Top contributors — an SVG horizontal bar chart: one
<rect>per contributor, with the login and commit count labelled as<text>. - Simple clean CSS, dark background.
4. Verify and report
- Sanity-check the HTML exists and carries both charts:
grep -c "<svg" .decode/outputs/dashboard.htmlshould print 2. - Tell the human to open it:
open .decode/outputs/dashboard.html.
Report the headline numbers (stars, forks, open issues), the busiest week of the year, the top contributor, and the one-line command to open the dashboard.