Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(profile): add a first-person About section and coding analytics to the personal GitHub profile

nirholas6495c47df86d
diff --git a/docs/github-growth.md b/docs/github-growth.md
index 096a6087c..5ad4e97c4 100644
--- a/docs/github-growth.md
+++ b/docs/github-growth.md
@@ -57,6 +57,32 @@ The README carries animated charts rendered by `scripts/lib/profile-visuals.mjs`
| `languages` | Extruded donut of primary languages that spins in 3D |
| `punchcard` | Repo creation by weekday and hour (UTC) |
+The same run adds an **About** section (the owner's background, first person) and a **How I build** section of coding analytics, rendered by `scripts/lib/profile-visuals.mjs` from numbers computed in `scripts/lib/profile-activity.mjs`:
+
+| Asset | What it shows |
+|---|---|
+| `activity-volume` | Odometer: commits, lines added and lines removed over the last 12 months |
+| `activity-habit` | Odometer: hours with a push, active days, longest streak |
+| `activity-calendar` | A year of daily commit counts as a calendar heatmap |
+| `activity-lines` | Lines added above the axis and removed below it, by month |
+| `activity-hours` | Hours of the day with a push, for each of the last 90 days, with the average |
+| `activity-rhythm` | Commits by weekday and hour (UTC) |
+
+Where the numbers come from, and what they leave out:
+
+- **Commits, active days and streaks** come from the GraphQL contribution calendar, so private repositories count (as counts only; no private name or content is ever read or printed).
+- **Lines and hours** come from each public, non-fork repo's default-branch history filtered to the owner (`history(author:)`, paged by an `until` date because cursor paging 502s deep into large repos). Private repos do not contribute.
+- **Bulk commits** over `BULK_LINES` (20,000) changed lines are left out of line totals as imports or generated output. A commit GitHub cannot diff comes back as a null node and is skipped.
+- **Hours are not a stopwatch.** A day counts each UTC clock hour in which a commit landed, so it can never exceed 24 and a single push never counts as more than its hour.
+- The README only ever names repos that survive the same gating as the catalog; gated repos still count toward totals.
+
+```bash
+node scripts/build-github-profile.mjs --out /tmp/profile # includes activity (cached 6h in $TMPDIR)
+node scripts/build-github-profile.mjs --out /tmp/profile --no-activity # catalog only, no history crawl
+```
+
+A cold run reads about 430 repos and takes a few minutes; the API quota cost is a few hundred GraphQL points.
+
GitHub shows README images through `<img>`, so there is no script or web font. The 3D is real anyway: a ring drawn in a group rotated by `animateTransform` and squashed by `scale(1, k)` is the exact projection of a ring spinning about a vertical axis, and dots and labels ride inside a counter-rotated group so they stay round and upright. The donut wall is the same rotating ring stacked every 1.5px. Section colors follow the fixed category order, so a section keeps its color in every chart.
## What GitHub's API cannot do
diff --git a/scripts/build-github-profile.mjs b/scripts/build-github-profile.mjs
index 74be0d244..d8340fd25 100644
--- a/scripts/build-github-profile.mjs
+++ b/scripts/build-github-profile.mjs
@@ -19,7 +19,8 @@
import { execFileSync, spawnSync } from 'node:child_process';
import { copyFileSync, existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
-import { renderVisuals } from './lib/profile-visuals.mjs';
+import { collectActivity, summarizeActivity } from './lib/profile-activity.mjs';
+import { renderActivityVisuals, renderVisuals } from './lib/profile-visuals.mjs';
import { OWNER, plain } from './lib/repo-growth-kit.mjs';
const args = process.argv.slice(2);
@@ -65,7 +66,44 @@ function load() {
.sort((a, b) => b.stargazerCount - a.stargazerCount || a.name.localeCompare(b.name));
}
-export function buildProfile(allRepos, { includeGated = false } = {}) {
+
+const hours = (h) => `${Math.round(h).toLocaleString('en-US')}`;
+const lines = (n) => n.toLocaleString('en-US');
+const longDate = (d) => new Date(`${d}T00:00:00Z`).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric', timeZone: 'UTC' });
+
+/** The "how I build" README section: charts, then the records and a table of where the lines went. */
+function activitySection(a, pic) {
+ const rows = a.topRepos.map((r) => `| [${r.name}](https://github.com/${OWNER}/${r.name}) | ${lines(r.commits)} | ${lines(r.added)} | ${lines(r.removed)} |`);
+ return `
+## How I build
+
+Pulled from the GitHub API on ${longDate(a.fetchedAt.slice(0, 10))}. Commit counts and streaks include private repositories as counts only. Lines and hours come from public repositories, with any commit over 20,000 changed lines left out as a bulk import. Hours are not a stopwatch: a day counts each clock hour (UTC) in which at least one commit landed, so it cannot pass 24.
+
+${pic('activity-volume', 'Commits, lines added and lines removed over the last 12 months')}
+
+${pic('activity-habit', 'Hours with a push, active days and longest streak')}
+
+${pic('activity-calendar', 'Calendar of daily commit counts for the last 365 days')}
+
+${pic('activity-lines', 'Lines added and removed per month')}
+
+${pic('activity-hours', 'Hours of the day with a push for each of the last 90 days')}
+
+${pic('activity-rhythm', 'Punchcard of commits by weekday and hour')}
+
+- Busiest day: ${longDate(a.totals.busiest.date)} with ${lines(a.totals.busiest.count)} commits.
+- Biggest day for lines: ${longDate(a.records.biggestDay.date)} with ${lines(a.records.biggestDay.lines)} lines changed.
+- Most hours with a push in one day: ${a.records.longestDay.hours} on ${longDate(a.records.longestDay.date)}.
+- Last 30 days: ${lines(a.last30.commits)} commits, ${lines(a.last30.added)} lines added and ${lines(a.last30.removed)} removed, pushes in ${lines(a.last30.hours)} separate hours on ${a.last30.activeDays} active days.
+- Current streak: ${a.totals.currentStreak} days. Longest: ${a.totals.longestStreak} days, ending ${longDate(a.totals.longestStreakEnd)}.
+
+| Where the lines went | Commits | Added | Removed |
+|---|---:|---:|---:|
+${rows.join('\n')}
+`;
+}
+
+export function buildProfile(allRepos, { includeGated = false, activityData = null, now = new Date() } = {}) {
const repos = includeGated ? allRepos : allRepos.filter((r) => !GATED.test(r.name) && !GATED.test(r.description || ''));
const totalStars = repos.reduce((n, r) => n + r.stargazerCount, 0);
const featured = repos.slice(0, 6);
@@ -76,6 +114,8 @@ export function buildProfile(allRepos, { includeGated = false } = {}) {
return { title, blurb, items, slot };
}).filter((g) => g.items.length);
const assets = renderVisuals(repos, groups);
+ const activity = activityData ? summarizeActivity(activityData, { now, allow: new Set(repos.map((r) => r.name)) }) : null;
+ if (activity) Object.assign(assets, renderActivityVisuals(activity));
const pic = (name, alt) =>
`<picture><source media="(prefers-color-scheme: dark)" srcset="./assets/${name}-dark.svg"/><source media="(prefers-color-scheme: light)" srcset="./assets/${name}-light.svg"/><img alt="${alt}" src="./assets/${name}-light.svg" width="100%"/></picture>`;
const anchor = (t) => t.toLowerCase().replace(/[^a-z0-9 -]/g, '').trim().replace(/\s+/g, '-');
@@ -94,6 +134,12 @@ export function buildProfile(allRepos, { includeGated = false } = {}) {
<p align="center">${pic('planet', `A rotating 3D planet with one point per repository, sized by stars and colored by section`)}</p>
+## About
+
+I studied Marketing and Computer Science at the University of Washington and finished with a double bachelor's. I have done security research for Apple, AT&T, Microsoft, Google, the U.S. Department of Defense and the State of California. Before building open source full time I wrote full-stack software for some of the largest companies and brands, and I write and contribute at Entrepreneur Magazine.
+
+Today I ship in public: AI agents, MCP servers, 3D, on-chain tooling and the developer tools around them, all documented so a person or a coding agent can pick them up cold.
+
## Start here
${featured.map(line).join('\n')}
@@ -107,11 +153,10 @@ Every chart below is rendered from the live GitHub listing each time the catalog
${pic('city', 'An isometric city with one tower per repository, height by stars, one district per section')}
${pic('growth', 'Cumulative repositories over time, stacked by section')}
-
${pic('languages', 'A spinning 3D donut of primary languages')}
${pic('punchcard', 'Punchcard of when repositories were created, by weekday and hour')}
-
+${activity ? activitySection(activity, pic) : ''}
## Find your way
Use the repository topics on the left of any repo, or jump to a section below. Every repo ships a README, an [AGENTS.md](https://agents.md) and an [llms.txt](https://llmstxt.org) so a coding agent can pick it up cold. The full machine-readable list is [repos.json](./repos.json).
@@ -201,7 +246,15 @@ authors:
if (import.meta.url === `file://${process.argv[1]}`) {
const all = load();
- const out = buildProfile(all, { includeGated: flag('include-gated') });
+ const activityData = flag('no-activity')
+ ? null
+ : await collectActivity({
+ owner: OWNER,
+ repos: JSON.parse(gh(['repo', 'list', OWNER, '--limit', '1000', '--json', 'name,isPrivate,isFork'])).filter((r) => !r.isPrivate && !r.isFork && r.name !== OWNER).map((r) => r.name),
+ cacheFile: join(process.env.TMPDIR || '/tmp', 'profile-activity-cache.json'),
+ log: console.log,
+ });
+ const out = buildProfile(all, { includeGated: flag('include-gated'), activityData });
rmSync(OUT, { recursive: true, force: true });
mkdirSync(OUT, { recursive: true });
writeFileSync(join(OUT, 'README.md'), out.readme);
diff --git a/scripts/lib/profile-activity.mjs b/scripts/lib/profile-activity.mjs
new file mode 100644
index 000000000..606e24780
--- /dev/null
+++ b/scripts/lib/profile-activity.mjs
@@ -0,0 +1,322 @@
+// Coding-activity analytics for the personal GitHub profile.
+//
+// Two halves. `collectActivity` reads real data from GitHub: the contribution
+// calendar (every commit the account made, private repos included, as counts
+// only) and, for every public repo, each of the owner's commits with its
+// timestamp and added and deleted lines. `summarizeActivity` is a pure function
+// over that data, so it is tested without the network and the visuals only ever
+// draw numbers computed here.
+//
+// Honest limits, repeated in the chart captions:
+// - Lines and time come from public repositories only. Private work shows up
+// in the commit and streak counts (the calendar) and nowhere else.
+// - Commits that change more than BULK_LINES lines are treated as bulk
+// imports or generated output and left out of the line totals, so a
+// regenerated lockfile or vendored folder cannot fake a record day.
+// - "Hours" is not a stopwatch. It counts the distinct clock hours of a day in
+// which at least one commit landed, so a day can never exceed 24 and a
+// single push never counts as more than the hour it was made in.
+// - Hours and weekdays are UTC.
+
+import { execFile } from 'node:child_process';
+import { existsSync, readFileSync, writeFileSync } from 'node:fs';
+import { promisify } from 'node:util';
+
+const run = promisify(execFile);
+
+export const BULK_LINES = 20000;
+const DAY = 86400000;
+const CONCURRENCY = 6;
+
+const HISTORY_QUERY = `query($owner:String!,$name:String!,$id:ID!,$until:GitTimestamp){
+ repository(owner:$owner,name:$name){
+ defaultBranchRef{target{... on Commit{history(first:100,until:$until,author:{id:$id}){
+ nodes{oid committedDate additions deletions}
+ }}}}
+ }
+}`;
+
+const CALENDAR_QUERY = `query($login:String!,$from:DateTime!,$to:DateTime!){
+ user(login:$login){contributionsCollection(from:$from,to:$to){
+ contributionCalendar{weeks{contributionDays{date contributionCount}}}
+ }}
+}`;
+
+function salvage(stdout) {
+ try {
+ const body = JSON.parse(stdout);
+ return body?.data ? body : null;
+ } catch {
+ return null;
+ }
+}
+
+async function ghJson(args) {
+ for (let attempt = 0; ; attempt++) {
+ try {
+ const { stdout } = await run('gh', args, { maxBuffer: 1 << 28 });
+ return JSON.parse(stdout);
+ } catch (err) {
+ // A commit too large for GitHub to diff makes gh exit non-zero while the
+ // body still carries every other commit, with a null in the failed slot.
+ const partial = salvage(err.stdout);
+ if (partial) return partial;
+ if (attempt >= 5) throw err;
+ await new Promise((r) => setTimeout(r, 2000 * (attempt + 1)));
+ }
+ }
+}
+
+const gql = (query, vars) =>
+ ghJson(['api', 'graphql', '-f', `query=${query}`, ...Object.entries(vars).flatMap(([k, v]) => [typeof v === 'number' ? '-F' : '-f', `${k}=${v}`])]);
+
+async function pool(items, size, fn) {
+ const out = new Array(items.length);
+ let next = 0;
+ await Promise.all(
+ Array.from({ length: Math.min(size, items.length) }, async () => {
+ while (next < items.length) {
+ const i = next++;
+ out[i] = await fn(items[i], i);
+ }
+ }),
+ );
+ return out;
+}
+
+/**
+ * Read one repo's history newest first, walking back with an `until` date
+ * instead of a cursor. A cursor makes GitHub skip over every earlier commit on
+ * each page, which times out (502) deep into a repo with thousands of commits;
+ * a date bound does not. Pages overlap by the boundary second, so commits are
+ * deduped by oid.
+ */
+async function repoCommits(owner, name, userId) {
+ const rows = [];
+ const seen = new Set();
+ let until = null;
+ for (;;) {
+ const vars = { owner, name, id: userId };
+ if (until) vars.until = until;
+ const res = await gql(HISTORY_QUERY, vars);
+ const nodes = res.data?.repository?.defaultBranchRef?.target?.history?.nodes;
+ if (!nodes?.length) break;
+ let fresh = 0;
+ for (const n of nodes) {
+ if (!n || seen.has(n.oid)) continue;
+ seen.add(n.oid);
+ fresh += 1;
+ rows.push([Date.parse(n.committedDate), n.additions, n.deletions]);
+ }
+ if (nodes.length < 100) break;
+ const oldest = Date.parse(nodes.findLast(Boolean).committedDate);
+ until = new Date(fresh ? oldest : oldest - 1000).toISOString();
+ }
+ return rows;
+}
+
+/**
+ * Fetch the raw activity. `repos` are the public, non-fork repository names to
+ * read history from. A finished run is written to `cacheFile` and reused for
+ * `cacheHours` so repeated builds while iterating on the visuals stay cheap.
+ */
+export async function collectActivity({ owner, repos, now = new Date(), cacheFile = null, cacheHours = 6, log = () => {} }) {
+ if (cacheFile && existsSync(cacheFile)) {
+ const cached = JSON.parse(readFileSync(cacheFile, 'utf8'));
+ if (cached.owner === owner && now - Date.parse(cached.fetchedAt) < cacheHours * 3600000) {
+ log(`activity: reusing cache from ${cached.fetchedAt}`);
+ return cached;
+ }
+ }
+ const user = await ghJson(['api', `users/${owner}`]);
+ const created = new Date(user.created_at);
+
+ const calendar = [];
+ const years = [];
+ for (let y = created.getUTCFullYear(); y <= now.getUTCFullYear(); y++) years.push(y);
+ await pool(years, 3, async (y) => {
+ const res = await gql(CALENDAR_QUERY, { login: owner, from: `${y}-01-01T00:00:00Z`, to: `${y}-12-31T23:59:59Z` });
+ for (const w of res.data.user.contributionsCollection.contributionCalendar.weeks)
+ for (const d of w.contributionDays) calendar.push([d.date, d.contributionCount]);
+ });
+ calendar.sort((a, b) => (a[0] < b[0] ? -1 : 1));
+
+ let done = 0;
+ const perRepo = await pool(repos, CONCURRENCY, async (name) => {
+ const rows = await repoCommits(owner, name, user.node_id);
+ if (++done % 50 === 0) log(`activity: ${done}/${repos.length} repos read`);
+ return [name, rows];
+ });
+ const commits = {};
+ for (const [name, rows] of perRepo) if (rows.length) commits[name] = rows;
+
+ const data = { owner, fetchedAt: now.toISOString(), calendar, commits };
+ if (cacheFile) writeFileSync(cacheFile, JSON.stringify(data));
+ return data;
+}
+
+const dayKey = (ms) => new Date(ms).toISOString().slice(0, 10);
+
+/**
+ * Turn raw activity into the numbers the charts draw. Pure: same input, same output.
+ * `allow` is an optional Set of repo names that may be named in the output; a repo
+ * outside it still counts toward every total but is never listed by name.
+ */
+export function summarizeActivity(data, { now = new Date(), allow = null } = {}) {
+ const calendar = new Map(data.calendar);
+ const today = dayKey(now.getTime());
+
+ // Every commit across public repos, one flat list, bulk commits flagged.
+ const flat = [];
+ const byRepo = new Map();
+ for (const [name, rows] of Object.entries(data.commits)) {
+ const stat = { name, commits: 0, added: 0, removed: 0 };
+ for (const [t, a, d] of rows) {
+ const bulk = a + d > BULK_LINES;
+ flat.push([t, bulk ? 0 : a, bulk ? 0 : d, bulk]);
+ stat.commits += 1;
+ if (!bulk) {
+ stat.added += a;
+ stat.removed += d;
+ }
+ }
+ byRepo.set(name, stat);
+ }
+ flat.sort((x, y) => x[0] - y[0]);
+
+ // Per-day roll-up: commits, lines and the distinct UTC hours with a push.
+ const days = new Map();
+ const day = (k) => {
+ let d = days.get(k);
+ if (!d) days.set(k, (d = { date: k, commits: 0, added: 0, removed: 0, slots: new Set() }));
+ return d;
+ };
+ for (const [t, a, d] of flat) {
+ const r = day(dayKey(t));
+ r.commits += 1;
+ r.added += a;
+ r.removed += d;
+ r.slots.add(new Date(t).getUTCHours());
+ }
+ for (const d of days.values()) d.hours = d.slots.size;
+
+ // Rhythm: weekday x hour of every commit, and hour-of-day share of time.
+ const rhythm = Array.from({ length: 7 }, () => Array(24).fill(0));
+ for (const [t] of flat) {
+ const d = new Date(t);
+ rhythm[(d.getUTCDay() + 6) % 7][d.getUTCHours()] += 1;
+ }
+
+ // Calendar-based streaks and counts cover private work too.
+ const calDays = [...calendar.entries()].filter(([k]) => k <= today);
+ let longest = 0;
+ let run = 0;
+ let longestEnd = null;
+ for (const [k, n] of calDays) {
+ run = n > 0 ? run + 1 : 0;
+ if (run > longest) {
+ longest = run;
+ longestEnd = k;
+ }
+ }
+ let current = 0;
+ for (let i = calDays.length - 1; i >= 0; i--) {
+ if (calDays[i][1] > 0) current += 1;
+ else if (i === calDays.length - 1 && calDays[i][0] === today) continue;
+ else break;
+ }
+ const calTotal = calDays.reduce((n, [, c]) => n + c, 0);
+ const activeDays = calDays.filter(([, c]) => c > 0).length;
+ let busiest = { date: null, count: 0 };
+ for (const [k, c] of calDays) if (c > busiest.count) busiest = { date: k, count: c };
+
+ // Trailing windows.
+ const windowFrom = (n) => dayKey(now.getTime() - (n - 1) * DAY);
+ const last = (n) => {
+ const from = windowFrom(n);
+ const rows = [...days.values()].filter((d) => d.date >= from && d.date <= today);
+ const cal = calDays.filter(([k]) => k >= from);
+ return {
+ commits: cal.reduce((s, [, c]) => s + c, 0),
+ added: rows.reduce((s, d) => s + d.added, 0),
+ removed: rows.reduce((s, d) => s + d.removed, 0),
+ hours: rows.reduce((s, d) => s + d.hours, 0),
+ activeDays: cal.filter(([, c]) => c > 0).length,
+ };
+ };
+ const d30 = last(30);
+ const d365 = last(365);
+
+ // Daily series for the last 365 days, calendar counts plus public lines and hours.
+ const series = [];
+ for (let i = 364; i >= 0; i--) {
+ const k = dayKey(now.getTime() - i * DAY);
+ const d = days.get(k);
+ series.push({ date: k, count: calendar.get(k) || 0, added: d?.added || 0, removed: d?.removed || 0, hours: d?.hours || 0 });
+ }
+
+ // Monthly lines for the last 24 months.
+ const months = [];
+ const nm = now.getUTCFullYear() * 12 + now.getUTCMonth();
+ for (let i = 23; i >= 0; i--) {
+ const m = nm - i;
+ months.push({ key: `${Math.floor(m / 12)}-${String((m % 12) + 1).padStart(2, '0')}`, added: 0, removed: 0, commits: 0, hours: 0 });
+ }
+ const monthIndex = new Map(months.map((m, i) => [m.key, i]));
+ for (const d of days.values()) {
+ const m = months[monthIndex.get(d.date.slice(0, 7))];
+ if (!m) continue;
+ m.added += d.added;
+ m.removed += d.removed;
+ m.commits += d.commits;
+ m.hours += d.hours;
+ }
+
+ const wanted = [...byRepo.values()].filter((r) => !allow || allow.has(r.name));
+ const topRepos = wanted.sort((a, b) => b.added + b.removed - (a.added + a.removed) || a.name.localeCompare(b.name)).slice(0, 8);
+
+ const totalAdded = flat.reduce((s, c) => s + c[1], 0);
+ const totalRemoved = flat.reduce((s, c) => s + c[2], 0);
+ const publicDays = [...days.values()].filter((d) => d.commits > 0);
+ const biggestDay = publicDays.reduce((m, d) => (d.added + d.removed > m.added + m.removed ? d : m), publicDays[0] || { date: null, added: 0, removed: 0 });
+ const longestDay = publicDays.reduce((m, d) => (d.hours > m.hours ? d : m), publicDays[0] || { date: null, hours: 0 });
+ const totalHours = publicDays.reduce((n, d) => n + d.hours, 0);
+ const peak = rhythm.flatMap((row, di) => row.map((v, h) => ({ v, di, h }))).reduce((m, c) => (c.v > m.v ? c : m), { v: -1, di: 0, h: 0 });
+
+ return {
+ fetchedAt: data.fetchedAt,
+ since: calDays.find(([, c]) => c > 0)?.[0] || today,
+ today,
+ series,
+ months,
+ rhythm,
+ peak,
+ topRepos,
+ totals: {
+ commits: calTotal,
+ publicCommits: flat.length,
+ added: totalAdded,
+ removed: totalRemoved,
+ net: totalAdded - totalRemoved,
+ bulkCommits: flat.filter((c) => c[3]).length,
+ hours: totalHours,
+ activeDays,
+ publicDays: publicDays.length,
+ longestStreak: longest,
+ longestStreakEnd: longestEnd,
+ currentStreak: current,
+ busiest,
+ },
+ averages: {
+ commitsPerActiveDay: activeDays ? calTotal / activeDays : 0,
+ hoursPerActiveDay: publicDays.length ? totalHours / publicDays.length : 0,
+ linesPerActiveDay: publicDays.length ? (totalAdded + totalRemoved) / publicDays.length : 0,
+ },
+ records: {
+ biggestDay: { date: biggestDay.date, lines: biggestDay.added + biggestDay.removed },
+ longestDay: { date: longestDay.date, hours: longestDay.hours },
+ },
+ last30: d30,
+ last365: d365,
+ };
+}
diff --git a/scripts/lib/profile-visuals.mjs b/scripts/lib/profile-visuals.mjs
index 5b4ded702..45f493f2f 100644
--- a/scripts/lib/profile-visuals.mjs
+++ b/scripts/lib/profile-visuals.mjs
@@ -13,6 +13,8 @@
// or invented. Each visual renders once per theme and the README picks one
// with <picture> and prefers-color-scheme.
+import { BULK_LINES } from './profile-activity.mjs';
+
const FONT = `-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif`;
// Categorical slots follow the section order in build-github-profile.mjs, so a
@@ -190,7 +192,7 @@ function planet(repos, groups, t) {
}
/** Odometer stat strip: each digit rolls into place on its own spline. */
-function odometer(stats, t) {
+function odometer(stats, t, title = 'Profile at a glance') {
const W = 900;
const H = 128;
const tw = W / stats.length;
@@ -227,7 +229,7 @@ function odometer(stats, t) {
body.push(`<text x="${r1(mid)}" y="${base + 26}" fill="${t.muted}" font-size="11.5" text-anchor="middle">${esc(s.caption)}</text>`);
});
out.push(`</defs>`);
- return svg(W, H, 'Profile at a glance', stats.map((s) => `${s.label}: ${fmt(s.value)} (${s.caption})`).join('. '), [...out, ...body].join('\n'));
+ return svg(W, H, title, stats.map((s) => `${s.label}: ${fmt(s.value)} (${s.caption})`).join('. '), [...out, ...body].join('\n'));
}
/** Isometric city: each section is a district, each repo a tower whose height is log stars. */
@@ -537,6 +539,11 @@ function punchcard(repos, t) {
const d = new Date(r.createdAt);
cells[(d.getUTCDay() + 6) % 7][d.getUTCHours()] += 1;
}
+ return punchGrid(cells, t, { title: 'When repositories are born', sub: (peak, v) => `Creation time of every repository by weekday and hour (UTC). Busiest slot: ${peak}, ${v} repos.`, desc: 'Punchcard of repository creation by weekday and hour, UTC.' });
+}
+
+/** Weekday by hour dot grid. Dot area is the count; the busiest slot is named in the caption. */
+function punchGrid(cells, t, { title, sub, desc }) {
const max = Math.max(1, ...cells.flat());
const W = 900;
const x0 = 74;
@@ -561,17 +568,179 @@ function punchcard(repos, t) {
for (let h = 0; h < 24; h += 3) out.push(`<text x="${r1(x0 + cw * (h + 0.5))}" y="${y0 - 22}" fill="${t.muted}" font-size="11" text-anchor="middle">${String(h).padStart(2, '0')}:00</text>`);
const style = `.p{transform-box:fill-box;transform-origin:center;animation:pop .7s cubic-bezier(.3,1.6,.5,1) both}@keyframes pop{from{transform:scale(0)}}`;
const peak = `${days[best.di]} ${String(best.h).padStart(2, '0')}:00 UTC`;
+ return svg(W, H, title, `${desc} Busiest slot: ${peak} with ${fmt(best.v)}.`, `${heading(t, 24, 36, title, sub(peak, fmt(best.v)))}
+${out.join('\n')}`, style);
+}
+
+
+const MONTH_NAMES = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+
+/** 10650561 becomes "10.7M", 48565 becomes "48.6k", small numbers stay whole. */
+const compact = (n) => (n >= 1e6 ? `${r1(n / 1e6)}M` : n >= 1e3 ? `${r1(n / 1e3)}k` : String(Math.round(n)));
+
+/** Twelve months of days as a calendar heatmap, one cell per day, colored by commit count. */
+function activityCalendar(a, t) {
+ const days = a.series;
+ const lead = (new Date(`${days[0].date}T00:00:00Z`).getUTCDay() + 6) % 7;
+ const cols = Math.ceil((lead + days.length) / 7);
+ const W = 900;
+ const x0 = 46;
+ const y0 = 84;
+ const step = (W - 24 - x0) / cols;
+ const size = step - 3;
+ const counts = days.map((d) => d.count).filter(Boolean).sort((p, q) => p - q);
+ const cut = [0.25, 0.5, 0.75].map((q) => counts[Math.floor(counts.length * q)] || 1);
+ const level = (n) => (n === 0 ? 0 : n <= cut[0] ? 1 : n <= cut[1] ? 2 : n <= cut[2] ? 3 : 4);
+ const opacity = [0, 0.3, 0.52, 0.76, 1];
+ const cells = [];
+ const labels = [];
+ let lastMonth = -1;
+ days.forEach((d, i) => {
+ const idx = lead + i;
+ const c = Math.floor(idx / 7);
+ const r = idx % 7;
+ const x = r1(x0 + c * step);
+ const y = r1(y0 + r * step);
+ const lv = level(d.count);
+ const fill = lv ? `fill="${t.seq}" fill-opacity="${opacity[lv]}"` : `fill="${t.grid}" fill-opacity="0.45"`;
+ cells.push(`<rect class="c" style="animation-delay:${r2(c * 0.025)}s" x="${x}" y="${y}" width="${r1(size)}" height="${r1(size)}" rx="2.5" ${fill}><title>${d.date}: ${fmt(d.count)} commits</title></rect>`);
+ const m = Number(d.date.slice(5, 7)) - 1;
+ if (r === 0 && m !== lastMonth && c < cols - 1) {
+ lastMonth = m;
+ labels.push(`<text x="${x}" y="${y0 - 10}" fill="${t.muted}" font-size="11">${MONTH_NAMES[m]}</text>`);
+ }
+ });
+ ['Mon', 'Wed', 'Fri'].forEach((n, k) => labels.push(`<text x="${x0 - 8}" y="${r1(y0 + k * 2 * step + size * 0.75)}" fill="${t.muted}" font-size="10.5" text-anchor="end">${n}</text>`));
+ const H = Math.ceil(y0 + 7 * step + 38);
+ const ly = H - 14;
+ const lx = W - 24 - 34;
+ const legend = [0, 1, 2, 3, 4].map((lv, k) => `<rect x="${lx - 14 * 5 + k * 14}" y="${ly - 10}" width="11" height="11" rx="2.5" ${lv ? `fill="${t.seq}" fill-opacity="${opacity[lv]}"` : `fill="${t.grid}" fill-opacity="0.45"`}/>`).join('');
+ const style = `.c{animation:fade .5s ease-out both}@keyframes fade{from{opacity:0}}`;
+ const l = a.last365;
+ return svg(
+ W,
+ H,
+ 'Twelve months of commits',
+ `Calendar of daily commit counts for the last 365 days: ${fmt(l.commits)} commits on ${l.activeDays} active days. Longest streak ${a.totals.longestStreak} days.`,
+ `${heading(t, 24, 36, 'Twelve months of commits', `${fmt(l.commits)} commits on ${l.activeDays} of the last 365 days, private repositories included as counts. Longest streak: ${a.totals.longestStreak} days.`)}
+${labels.join('\n')}
+${cells.join('\n')}
+<text x="${lx - 14 * 5 - 8}" y="${ly - 1}" fill="${t.muted}" font-size="10.5" text-anchor="end">Less</text>${legend}<text x="${lx + 4}" y="${ly - 1}" fill="${t.muted}" font-size="10.5">More</text>`,
+ style,
+ );
+}
+
+/** Lines added above the axis and removed below it, by month, for two years. */
+function activityLines(a, t) {
+ const first = a.months.findIndex((m) => m.commits > 0);
+ const months = a.months.slice(Math.min(Math.max(first, 0), a.months.length - 12));
+ const W = 900;
+ const H = 330;
+ const x0 = 62;
+ const x1 = W - 24;
+ const mid = 196;
+ const up = 100;
+ const down = 70;
+ const peak = Math.max(1, ...months.map((m) => m.added));
+ const peakDown = Math.max(1, ...months.map((m) => m.removed));
+ const unit = Math.min(up / peak, down / peakDown);
+ const bw = (x1 - x0) / months.length;
+ const bars = [];
+ const ticks = [];
+ const nice = [1e3, 2e3, 5e3, 1e4, 2e4, 5e4, 1e5, 2e5, 5e5, 1e6, 2e6, 5e6].find((v) => up / unit / v <= 4) || 1e7;
+ for (let v = nice; v * unit <= up; v += nice) ticks.push(`<line x1="${x0}" y1="${r1(mid - v * unit)}" x2="${x1}" y2="${r1(mid - v * unit)}" stroke="${t.grid}" stroke-opacity="0.5"/><text x="${x0 - 8}" y="${r1(mid - v * unit + 4)}" fill="${t.muted}" font-size="11" text-anchor="end">${compact(v)}</text>`);
+ months.forEach((m, i) => {
+ const x = r1(x0 + i * bw + bw * 0.14);
+ const w = r1(bw * 0.72);
+ const hu = r1(m.added * unit);
+ const hd = r1(m.removed * unit);
+ const delay = r2(i * 0.05);
+ const name = `${MONTH_NAMES[Number(m.key.slice(5)) - 1]} ${m.key.slice(2, 4)}`;
+ if (hu > 0) bars.push(`<rect class="b" style="animation-delay:${delay}s;transform-origin:${r1(x + w / 2)}px ${mid}px" x="${x}" y="${r1(mid - hu)}" width="${w}" height="${hu}" rx="2" fill="${t.series[2]}"><title>${name}: ${fmt(m.added)} added, ${fmt(m.removed)} removed, ${fmt(m.commits)} commits</title></rect>`);
+ if (hd > 0) bars.push(`<rect class="b" style="animation-delay:${delay}s;transform-origin:${r1(x + w / 2)}px ${mid}px" x="${x}" y="${mid}" width="${w}" height="${hd}" rx="2" fill="${t.series[1]}"/>`);
+ if (i % 3 === 0 || i === months.length - 1) ticks.push(`<text x="${r1(x + w / 2)}" y="${mid + down + 24}" fill="${t.muted}" font-size="11" text-anchor="middle">${name}</text>`);
+ });
+ const l = a.last365;
+ const style = `.b{transform-box:view-box;animation:grow .8s cubic-bezier(.2,.9,.3,1) both}@keyframes grow{from{transform:scaleY(0)}}`;
return svg(
W,
H,
- 'When repositories are born',
- `Punchcard of repository creation by weekday and hour, UTC. Busiest slot: ${peak} with ${best.v}.`,
- `${heading(t, 24, 36, 'When repositories are born', `Creation time of every repository by weekday and hour (UTC). Busiest slot: ${peak}, ${best.v} repos.`)}
-${out.join('\n')}`,
+ 'Lines of code pushed',
+ `Lines added and removed per month, from the first month with public commits. Last 12 months: ${fmt(l.added)} added, ${fmt(l.removed)} removed.`,
+ `${heading(t, 24, 36, 'Lines of code pushed', `Last 12 months: ${compact(l.added)} added, ${compact(l.removed)} removed. Public repositories, commits over ${compact(BULK_LINES)} lines left out.`)}
+${ticks.join('\n')}
+<line x1="${x0}" y1="${mid}" x2="${x1}" y2="${mid}" stroke="${t.muted}"/>
+${bars.join('\n')}
+<rect x="${x1 - 150}" y="62" width="10" height="10" rx="2" fill="${t.series[2]}"/><text x="${x1 - 134}" y="71" fill="${t.sub}" font-size="11.5">added</text>
+<rect x="${x1 - 76}" y="62" width="10" height="10" rx="2" fill="${t.series[1]}"/><text x="${x1 - 60}" y="71" fill="${t.sub}" font-size="11.5">removed</text>`,
style,
);
}
+/** Hours of the day with a push, per day, for the last 90 days. */
+function activityHours(a, t) {
+ const days = a.series.slice(-90);
+ const W = 900;
+ const H = 300;
+ const x0 = 54;
+ const x1 = W - 24;
+ const y0 = 238;
+ const y1 = 84;
+ const bw = (x1 - x0) / days.length;
+ const Y = (h) => y0 - ((y0 - y1) * h) / 24;
+ const active = days.filter((d) => d.hours > 0);
+ const avg = active.length ? active.reduce((n, d) => n + d.hours, 0) / active.length : 0;
+ const grid = [0, 6, 12, 18, 24].map((h) => `<line x1="${x0}" y1="${r1(Y(h))}" x2="${x1}" y2="${r1(Y(h))}" stroke="${t.grid}" stroke-opacity="${h ? 0.55 : 1}"/><text x="${x0 - 8}" y="${r1(Y(h) + 4)}" fill="${t.muted}" font-size="11" text-anchor="end">${h}h</text>`);
+ const bars = [];
+ days.forEach((d, i) => {
+ const x = r1(x0 + i * bw + bw * 0.12);
+ const w = r1(bw * 0.76);
+ if (d.hours > 0) bars.push(`<rect class="b" style="animation-delay:${r2(i * 0.012)}s;transform-origin:${r1(x + w / 2)}px ${y0}px" x="${x}" y="${r1(Y(d.hours))}" width="${w}" height="${r1(y0 - Y(d.hours))}" rx="1.5" fill="${t.seq}"><title>${d.date}: pushes in ${d.hours} different hours, ${fmt(d.count)} commits</title></rect>`);
+ else bars.push(`<rect x="${x}" y="${y0 - 2}" width="${w}" height="2" rx="1" fill="${t.grid}"/>`);
+ if (i % 15 === 0) grid.push(`<text x="${r1(x + w / 2)}" y="${y0 + 18}" fill="${t.muted}" font-size="11" text-anchor="middle">${MONTH_NAMES[Number(d.date.slice(5, 7)) - 1]} ${Number(d.date.slice(8))}</text>`);
+ });
+ const style = `.b{transform-box:view-box;animation:grow .7s cubic-bezier(.2,.9,.3,1) both}@keyframes grow{from{transform:scaleY(0)}}`;
+ return svg(
+ W,
+ H,
+ 'Hours per day',
+ `Distinct hours of the day with a push, for each of the last 90 days. Average ${r1(avg)} on days with pushes; ${active.length} of 90 days active.`,
+ `${heading(t, 24, 36, 'Hours per day', `Distinct hours of the day with a push, last 90 days. Average ${r1(avg)}h on the ${active.length} days with pushes (public repositories, UTC).`)}
+${grid.join('\n')}
+${bars.join('\n')}
+<line x1="${x0}" y1="${r1(Y(avg))}" x2="${x1}" y2="${r1(Y(avg))}" stroke="${t.text}" stroke-dasharray="5 4" stroke-opacity="0.7"/><text x="${x1}" y="${r1(Y(avg) - 6)}" fill="${t.text}" font-size="11.5" text-anchor="end">avg ${r1(avg)}h</text>`,
+ style,
+ );
+}
+
+/**
+ * Render the coding-activity visuals for both themes from a summarizeActivity() result.
+ * Returns { 'activity-volume-dark.svg': svg, ... }.
+ */
+export function renderActivityVisuals(a) {
+ const l = a.last365;
+ const volume = [
+ { label: 'Commits, 12 months', value: l.commits, caption: 'every repo, private as counts' },
+ { label: 'Lines added', value: l.added, caption: 'public repos, last 12 months' },
+ { label: 'Lines removed', value: l.removed, caption: 'public repos, last 12 months' },
+ ];
+ const habit = [
+ { label: 'Hours with a push', value: l.hours, caption: `${r1(a.averages.hoursPerActiveDay)} per active day` },
+ { label: 'Active days', value: l.activeDays, caption: 'of the last 365' },
+ { label: 'Longest streak', value: a.totals.longestStreak, caption: 'days in a row, all time' },
+ ];
+ const files = {};
+ for (const [name, t] of Object.entries(THEMES)) {
+ files[`activity-volume-${name}.svg`] = odometer(volume, t, 'Code pushed in the last 12 months');
+ files[`activity-habit-${name}.svg`] = odometer(habit, t, 'How often I build');
+ files[`activity-calendar-${name}.svg`] = activityCalendar(a, t);
+ files[`activity-lines-${name}.svg`] = activityLines(a, t);
+ files[`activity-hours-${name}.svg`] = activityHours(a, t);
+ files[`activity-rhythm-${name}.svg`] = punchGrid(a.rhythm, t, { title: 'When the code lands', sub: (peak, v) => `Commits by weekday and hour (UTC) across public repositories. Busiest slot: ${peak}, ${v} commits.`, desc: 'Punchcard of commits by weekday and hour, UTC.' });
+ }
+ return files;
+}
+
/**
* Render every visual for both themes.
* `repos` is sorted by stars, descending; `groups` carry `slot`, the section's
diff --git a/tests/github-profile.test.js b/tests/github-profile.test.js
index 6e5e4f7c7..5c75f6450 100644
--- a/tests/github-profile.test.js
+++ b/tests/github-profile.test.js
@@ -1,6 +1,7 @@
import { describe, it, expect } from 'vitest';
import { buildProfile } from '../scripts/build-github-profile.mjs';
-import { renderVisuals, shortTitle } from '../scripts/lib/profile-visuals.mjs';
+import { renderVisuals, renderActivityVisuals, shortTitle } from '../scripts/lib/profile-visuals.mjs';
+import { summarizeActivity, BULK_LINES } from '../scripts/lib/profile-activity.mjs';
const repo = (name, stars, extra = {}) => ({
name,
@@ -63,4 +64,91 @@ describe('github profile', () => {
expect(shortTitle('Developer tools and everything else')).toBe('Developer tools');
expect(shortTitle('MCP servers for AI agents')).toBe('MCP servers');
});
+
+ describe('coding activity', () => {
+ const now = new Date('2026-10-11T12:00:00Z');
+ const ms = (iso) => Date.parse(iso);
+ const data = {
+ owner: 'nirholas',
+ fetchedAt: '2026-10-11T12:00:00.000Z',
+ calendar: [
+ ['2026-10-05', 3],
+ ['2026-10-06', 0],
+ ['2026-10-07', 5],
+ ['2026-10-08', 2],
+ ['2026-10-09', 4],
+ ['2026-10-10', 1],
+ ['2026-10-11', 0],
+ ],
+ commits: {
+ 'big-tool': [
+ [ms('2026-10-09T10:05:00Z'), 100, 20],
+ [ms('2026-10-09T10:40:00Z'), 50, 5],
+ [ms('2026-10-09T15:00:00Z'), 10, 0],
+ [ms('2026-10-10T02:30:00Z'), BULK_LINES + 1, 0],
+ ],
+ 'agent-mcp': [[ms('2026-10-07T23:59:00Z'), 7, 3]],
+ 'hidden-thing': [[ms('2026-10-08T09:00:00Z'), 1000, 0]],
+ },
+ };
+ const sum = summarizeActivity(data, { now, allow: new Set(['big-tool', 'agent-mcp']) });
+
+ it('counts hours as distinct clock hours with a push, never more than 24 a day', () => {
+ const nineth = sum.series.find((d) => d.date === '2026-10-09');
+ expect(nineth.hours).toBe(2);
+ expect(Math.max(...sum.series.map((d) => d.hours))).toBeLessThanOrEqual(24);
+ expect(sum.totals.hours).toBe(5);
+ });
+
+ it('leaves bulk commits out of the line totals but still counts them as commits', () => {
+ expect(sum.totals.added).toBe(100 + 50 + 10 + 7 + 1000);
+ expect(sum.totals.removed).toBe(20 + 5 + 3);
+ expect(sum.totals.bulkCommits).toBe(1);
+ expect(sum.totals.publicCommits).toBe(6);
+ });
+
+ it('takes streaks and commit counts from the calendar, which includes private work', () => {
+ expect(sum.totals.commits).toBe(15);
+ expect(sum.totals.activeDays).toBe(5);
+ expect(sum.totals.longestStreak).toBe(4);
+ expect(sum.totals.longestStreakEnd).toBe('2026-10-10');
+ expect(sum.totals.currentStreak).toBe(4);
+ expect(sum.totals.busiest).toEqual({ date: '2026-10-07', count: 5 });
+ });
+
+ it('never names a repo outside the allow list, yet still counts its commits', () => {
+ expect(sum.topRepos.map((r) => r.name)).toEqual(['big-tool', 'agent-mcp']);
+ expect(JSON.stringify(sum)).not.toContain('hidden-thing');
+ });
+
+ it('places each commit in its UTC weekday and hour', () => {
+ const friday = 4;
+ expect(sum.rhythm[friday][10]).toBe(2);
+ expect(sum.rhythm.flat().reduce((n, v) => n + v, 0)).toBe(sum.totals.publicCommits);
+ });
+
+ it('renders every activity chart in both themes as well-formed SVG', () => {
+ const files = renderActivityVisuals(sum);
+ const names = ['activity-volume', 'activity-habit', 'activity-calendar', 'activity-lines', 'activity-hours', 'activity-rhythm'];
+ expect(Object.keys(files).sort()).toEqual(names.flatMap((n) => [`${n}-dark.svg`, `${n}-light.svg`]).sort());
+ for (const body of Object.values(files)) {
+ expect(body.startsWith('<svg xmlns="http://www.w3.org/2000/svg"')).toBe(true);
+ expect(body.match(/<g\b/g)?.length ?? 0).toBe(body.match(/<\/g>/g)?.length ?? 0);
+ expect(body).not.toMatch(/NaN|undefined|Infinity/);
+ }
+ expect(files['activity-volume-dark.svg']).toContain('Commits, 12 months: 15');
+ });
+
+ it('adds the about section and the activity section to the profile, and omits the latter without data', () => {
+ const withData = buildProfile(repos, { activityData: data, now });
+ expect(withData.readme).toContain('## About');
+ expect(withData.readme).toContain('## How I build');
+ expect(withData.readme).toContain('srcset="./assets/activity-calendar-dark.svg"');
+ expect(withData.readme).toContain('| [big-tool](https://github.com/nirholas/big-tool) |');
+ expect(withData.assets['activity-hours-light.svg']).toBeDefined();
+ const without = buildProfile(repos);
+ expect(without.readme).toContain('## About');
+ expect(without.readme).not.toContain('## How I build');
+ });
+ });
});