Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

docs: publish the contributors wall on the default branch

tt-a1i05720ab022d4
diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml
new file mode 100644
index 00000000..f09b5cd1
--- /dev/null
+++ b/.github/workflows/contributors.yml
@@ -0,0 +1,30 @@
+name: Contributors
+
+on:
+ schedule:
+ # Weekly, after the Monday star-history refresh, so the two publishers do not overlap.
+ - cron: '15 5 * * 1'
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+concurrency:
+ group: contributors-svg
+ cancel-in-progress: true
+
+jobs:
+ update:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
+ - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
+ with:
+ node-version: 22
+ - name: Render contributors wall
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: node scripts/generate-contributors-svg.mjs --out "$RUNNER_TEMP/contributors.svg"
+ - name: Publish wall with linear history
+ run: bash scripts/publish-contributors-svg.sh contributors "$RUNNER_TEMP/contributors.svg"
diff --git a/README.md b/README.md
index 3ca6f50c..198aab07 100644
--- a/README.md
+++ b/README.md
@@ -518,6 +518,12 @@ Scan the QR code below with Alipay, or save it and open it in Alipay to scan.
Using Archify, sharing it, reporting bugs, and contributing improvements are also ways to help.
+## Contributors
+
+Thanks to everyone who helped build Archify. [Go follow them.](https://github.com/tt-a1i/archify/graphs/contributors) ❤️
+
+<p align="center"><a href="https://github.com/tt-a1i/archify/graphs/contributors"><img alt="Archify contributors" src="https://raw.githubusercontent.com/tt-a1i/archify/contributors/contributors.svg" width="1000" /></a></p>
+
## Star History
<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-dark.svg" /><img alt="Star History" src="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-light.svg" /></picture></p>
diff --git a/README_EN.md b/README_EN.md
index 3ca6f50c..198aab07 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -518,6 +518,12 @@ Scan the QR code below with Alipay, or save it and open it in Alipay to scan.
Using Archify, sharing it, reporting bugs, and contributing improvements are also ways to help.
+## Contributors
+
+Thanks to everyone who helped build Archify. [Go follow them.](https://github.com/tt-a1i/archify/graphs/contributors) ❤️
+
+<p align="center"><a href="https://github.com/tt-a1i/archify/graphs/contributors"><img alt="Archify contributors" src="https://raw.githubusercontent.com/tt-a1i/archify/contributors/contributors.svg" width="1000" /></a></p>
+
## Star History
<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-dark.svg" /><img alt="Star History" src="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-light.svg" /></picture></p>
diff --git a/README_JA.md b/README_JA.md
index 79165719..69652fd8 100644
--- a/README_JA.md
+++ b/README_JA.md
@@ -486,6 +486,12 @@ Alipay で下の QR コードをスキャンするか、画像を保存して Al
利用、共有、不具合の報告、改善への貢献も、プロジェクトの支えになります。
+## コントリビューター
+
+Archify の開発を支えてくれたすべての人に感謝します。[フォローしてみてください。](https://github.com/tt-a1i/archify/graphs/contributors) ❤️
+
+<p align="center"><a href="https://github.com/tt-a1i/archify/graphs/contributors"><img alt="Archify のコントリビューター" src="https://raw.githubusercontent.com/tt-a1i/archify/contributors/contributors.svg" width="1000" /></a></p>
+
## Star History
<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-dark.svg" /><img alt="Star History" src="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-light.svg" /></picture></p>
diff --git a/README_KO.md b/README_KO.md
index 1e332ee6..9fcf58eb 100644
--- a/README_KO.md
+++ b/README_KO.md
@@ -227,6 +227,12 @@ node bin/archify.mjs validate workflow examples/agent-tool-call.workflow.json --
Issue, Pull Request, 실제 사용 사례 다이어그램을 환영합니다. [기여 가이드](CONTRIBUTING.md)에서 시작하세요. 실패는 재현 가능한 버그 양식으로 제보하고, 검증된 다이어그램은 [커뮤니티 Showcase 양식](https://github.com/tt-a1i/archify/issues/new?template=showcase.yml)으로 제출할 수 있습니다.
+## 기여자
+
+Archify를 함께 만들어 준 모든 분께 감사합니다. [팔로우해 보세요.](https://github.com/tt-a1i/archify/graphs/contributors) ❤️
+
+<p align="center"><a href="https://github.com/tt-a1i/archify/graphs/contributors"><img alt="Archify 기여자" src="https://raw.githubusercontent.com/tt-a1i/archify/contributors/contributors.svg" width="1000" /></a></p>
+
## Star History
<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-dark.svg" /><img alt="Star History" src="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-light.svg" /></picture></p>
diff --git a/README_ZH.md b/README_ZH.md
index 81854668..85a3474a 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -524,6 +524,12 @@ node bin/archify.mjs deliver workflow examples/agent-tool-call.workflow.json /tm
使用、分享、反馈问题和贡献改进,也都是对项目的支持。
+## 贡献者
+
+感谢每一位参与构建 Archify 的人。[欢迎关注他们。](https://github.com/tt-a1i/archify/graphs/contributors) ❤️
+
+<p align="center"><a href="https://github.com/tt-a1i/archify/graphs/contributors"><img alt="Archify 贡献者" src="https://raw.githubusercontent.com/tt-a1i/archify/contributors/contributors.svg" width="1000" /></a></p>
+
## Star History
<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-dark.svg" /><img alt="Star History" src="https://raw.githubusercontent.com/tt-a1i/archify/star-history/assets/star-history-light.svg" /></picture></p>
diff --git a/scripts/generate-contributors-svg.mjs b/scripts/generate-contributors-svg.mjs
new file mode 100755
index 00000000..ce4c2d0b
--- /dev/null
+++ b/scripts/generate-contributors-svg.mjs
@@ -0,0 +1,258 @@
+#!/usr/bin/env node
+// Builds a README contributors wall from the GitHub contributors API.
+// Avatar bytes are inlined as base64 so GitHub's image proxy does not have to
+// fetch nested images. The scheduled workflow publishes the file on a data
+// branch; this script does not commit.
+
+import fs from 'node:fs';
+import { pathToFileURL } from 'node:url';
+
+const WALL_WIDTH = 1000;
+const COLUMNS = 8;
+const AVATAR = 72;
+const CELL_WIDTH = WALL_WIDTH / COLUMNS;
+const AVATAR_X = (CELL_WIDTH - AVATAR) / 2;
+const AVATAR_Y = 8;
+const NAME_LIMIT = 18;
+const ROW_HEIGHT = AVATAR_Y + AVATAR + 36;
+const MAX_AVATAR_BYTES = 1_500_000;
+
+// Exact logins, plus any account GitHub marks as a Bot or names with [bot].
+// "claude" is the unscoped Claude app login, not a substring of human names.
+const BOT_LOGINS = new Set([
+ 'allcontributors',
+ 'claude',
+ 'codecov',
+ 'copilot',
+ 'dependabot',
+ 'dependabot-preview',
+ 'github-actions',
+ 'imgbot',
+ 'pre-commit-ci',
+ 'renovate',
+ 'snyk-bot',
+ 'web-flow',
+]);
+
+const LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/;
+
+export function isBotContributor(user) {
+ if (!user || typeof user.login !== 'string') return true;
+ if (user.type === 'Bot') return true;
+ const login = user.login.trim();
+ if (/\[bot\]$/i.test(login)) return true;
+ return BOT_LOGINS.has(login.toLowerCase());
+}
+
+export function displayLogin(login) {
+ if (login.length <= NAME_LIMIT) return login;
+ return `${login.slice(0, NAME_LIMIT - 1)}…`;
+}
+
+export function avatarMediaType(bytes, headerType = '') {
+ if (bytes.length >= 8 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) return 'image/png';
+ if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return 'image/jpeg';
+ const gif = bytes.length >= 6 ? bytes.subarray(0, 6).toString('ascii') : '';
+ if (gif === 'GIF87a' || gif === 'GIF89a') return 'image/gif';
+ if (bytes.length >= 12 && bytes.subarray(0, 4).toString('ascii') === 'RIFF' && bytes.subarray(8, 12).toString('ascii') === 'WEBP') return 'image/webp';
+ const normalized = String(headerType).split(';')[0].trim().toLowerCase();
+ if (['image/png', 'image/jpeg', 'image/gif', 'image/webp'].includes(normalized)) return normalized;
+ throw new Error('Avatar is not a PNG, JPEG, GIF, or WebP image');
+}
+
+function xmlEscape(value) {
+ return value.replace(/[&<>"']/g, (char) => ({
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&apos;',
+ }[char]));
+}
+
+function repoParts(repo) {
+ const match = /^([^/\s]+)\/([^/\s]+)$/.exec(repo || '');
+ if (!match) throw new Error('Repository must look like owner/name');
+ return { owner: match[1], name: match[2] };
+}
+
+function githubHeaders(token, accept = 'application/vnd.github+json') {
+ const headers = {
+ Accept: accept,
+ 'User-Agent': 'archify-contributors-svg',
+ 'X-GitHub-Api-Version': '2022-11-28',
+ };
+ if (token) headers.Authorization = `Bearer ${token}`;
+ return headers;
+}
+
+function nextPage(linkHeader) {
+ if (!linkHeader) return '';
+ for (const part of linkHeader.split(',')) {
+ const match = /<([^>]+)>;\s*rel="next"/.exec(part);
+ if (!match) continue;
+ const url = new URL(match[1]);
+ if (url.protocol !== 'https:' || url.hostname !== 'api.github.com') {
+ throw new Error('Refusing contributors pagination outside api.github.com');
+ }
+ return url.href;
+ }
+ return '';
+}
+
+export async function fetchContributors({ repo = 'tt-a1i/archify', token = '', fetchImpl = fetch } = {}) {
+ const { owner, name } = repoParts(repo);
+ let url = `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/contributors?per_page=100`;
+ const people = [];
+ const seen = new Set();
+ while (url) {
+ const response = await fetchImpl(url, {
+ headers: githubHeaders(token),
+ signal: AbortSignal.timeout(20_000),
+ });
+ if (!response.ok) throw new Error(`GitHub contributors request failed (${response.status})`);
+ const page = await response.json();
+ if (!Array.isArray(page)) throw new Error('GitHub contributors response was not a list');
+ for (const user of page) {
+ if (isBotContributor(user) || seen.has(user.login)) continue;
+ if (!LOGIN.test(user.login)) continue;
+ seen.add(user.login);
+ people.push({
+ login: user.login,
+ contributions: Number(user.contributions) || 0,
+ avatarUrl: user.avatar_url,
+ });
+ }
+ url = nextPage(response.headers.get('link'));
+ }
+ people.sort((a, b) => b.contributions - a.contributions || a.login.localeCompare(b.login));
+ if (!people.length) throw new Error('No human contributors to render');
+ return people;
+}
+
+function avatarRequestUrl(avatarUrl, login) {
+ let url;
+ try {
+ url = new URL(avatarUrl);
+ } catch {
+ throw new Error(`Contributor ${login} has no avatar URL`);
+ }
+ if (url.protocol !== 'https:' || !['avatars.githubusercontent.com', 'github.com'].includes(url.hostname)) {
+ throw new Error(`Refusing avatar host for ${login}`);
+ }
+ url.searchParams.set('s', '144');
+ return url;
+}
+
+export async function fetchAvatarDataUri(person, { fetchImpl = fetch } = {}) {
+ let requested = avatarRequestUrl(person.avatarUrl, person.login);
+ let response;
+ for (let redirects = 0; ; redirects += 1) {
+ // Avatars are public. Keep the API token on the API request path only.
+ response = await fetchImpl(requested, {
+ headers: githubHeaders('', 'application/octet-stream'),
+ redirect: 'manual',
+ signal: AbortSignal.timeout(20_000),
+ });
+ if (![301, 302, 303, 307, 308].includes(response.status)) break;
+ await response.body?.cancel();
+ const location = response.headers.get('location');
+ if (!location) throw new Error(`Avatar redirect has no location for ${person.login}`);
+ if (redirects >= 5) throw new Error(`Too many avatar redirects for ${person.login}`);
+ // Validate each hop before fetching it, including HTTPS and allowed hosts.
+ requested = avatarRequestUrl(new URL(location, requested).href, person.login);
+ }
+ if (!response.ok) throw new Error(`Avatar download failed for ${person.login} (${response.status})`);
+ avatarRequestUrl(response.url || requested, person.login);
+ const bytes = Buffer.from(await response.arrayBuffer());
+ if (bytes.length === 0 || bytes.length > MAX_AVATAR_BYTES) {
+ throw new Error(`Avatar for ${person.login} is empty or larger than ${MAX_AVATAR_BYTES} bytes`);
+ }
+ const mediaType = avatarMediaType(bytes, response.headers.get('content-type') || '');
+ return `data:${mediaType};base64,${bytes.toString('base64')}`;
+}
+
+export function renderContributorsSvg(contributors) {
+ if (!Array.isArray(contributors) || contributors.length === 0) {
+ throw new Error('No human contributors to render');
+ }
+ const rows = Math.ceil(contributors.length / COLUMNS);
+ const cells = contributors.map((person, index) => {
+ if (!person || !LOGIN.test(person.login || '')) throw new Error('Contributor login is not a GitHub login');
+ if (!/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/=]+$/.test(person.dataUri || '')) {
+ throw new Error(`Contributor ${person.login} is missing an inline avatar`);
+ }
+ const column = index % COLUMNS;
+ const row = Math.floor(index / COLUMNS);
+ const label = displayLogin(person.login);
+ const centerX = AVATAR_X + AVATAR / 2;
+ const centerY = AVATAR_Y + AVATAR / 2;
+ return ` <g transform="translate(${column * CELL_WIDTH} ${row * ROW_HEIGHT})">
+ <title>${xmlEscape(person.login)}</title>
+ <defs><clipPath id="archify-contributor-${index}"><circle cx="${centerX}" cy="${centerY}" r="${AVATAR / 2}"/></clipPath></defs>
+ <image href="${person.dataUri}" x="${AVATAR_X}" y="${AVATAR_Y}" width="${AVATAR}" height="${AVATAR}" clip-path="url(#archify-contributor-${index})" preserveAspectRatio="xMidYMid slice"/>
+ <circle class="ring" cx="${centerX}" cy="${centerY}" r="${AVATAR / 2}" fill="none" stroke-width="1"/>
+ <text class="name" x="${centerX}" y="${AVATAR_Y + AVATAR + 22}" text-anchor="middle">${xmlEscape(label)}</text>
+ </g>`;
+ });
+ return `<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="${WALL_WIDTH}" height="${rows * ROW_HEIGHT}" viewBox="0 0 ${WALL_WIDTH} ${rows * ROW_HEIGHT}" role="img">
+ <title>Archify contributors</title>
+ <style><![CDATA[
+ .name { fill: #24292f; stroke: #ffffff; stroke-width: 3px; paint-order: stroke fill; font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 12px; }
+ .ring { stroke: #d0d7de; }
+ @media (prefers-color-scheme: dark) {
+ .name { fill: #f0f6fc; stroke: #010409; }
+ .ring { stroke: #30363d; }
+ }
+ ]]></style>
+${cells.join('\n')}
+</svg>
+`;
+}
+
+export async function buildContributorsSvg(options = {}) {
+ const people = await fetchContributors(options);
+ const rendered = [];
+ for (const person of people) {
+ rendered.push({
+ login: person.login,
+ dataUri: await fetchAvatarDataUri(person, options),
+ });
+ }
+ return renderContributorsSvg(rendered);
+}
+
+function parseArgs(argv) {
+ const options = { repo: 'tt-a1i/archify', out: '' };
+ for (let index = 0; index < argv.length; index += 1) {
+ const arg = argv[index];
+ if (arg === '--repo') options.repo = argv[++index];
+ else if (arg === '--out') options.out = argv[++index];
+ else if (arg === '--help' || arg === '-h') options.help = true;
+ else throw new Error(`Unknown argument: ${arg}`);
+ if (options.repo === undefined || options.out === undefined) throw new Error(`Missing value for ${arg}`);
+ }
+ return options;
+}
+
+async function main(argv, env = process.env) {
+ const options = parseArgs(argv);
+ if (options.help) {
+ console.log('Usage: node scripts/generate-contributors-svg.mjs [--repo owner/name] [--out file]');
+ return;
+ }
+ const svg = await buildContributorsSvg({
+ repo: options.repo,
+ token: env.GH_TOKEN || env.GITHUB_TOKEN || '',
+ });
+ if (options.out) fs.writeFileSync(options.out, svg);
+ else process.stdout.write(svg);
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ main(process.argv.slice(2)).catch((error) => {
+ console.error(error.message);
+ process.exit(1);
+ });
+}
diff --git a/scripts/publish-contributors-svg.sh b/scripts/publish-contributors-svg.sh
new file mode 100755
index 00000000..073350e4
--- /dev/null
+++ b/scripts/publish-contributors-svg.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# Publishes one generated contributors.svg onto a dedicated data branch.
+# Same linear fast-forward pattern as scripts/publish-star-history.sh: the
+# branch contains only that file, and this script never commits on main or dev.
+# Maintainer-only GitHub Actions helper; it is not part of the Archify CLI.
+
+set -euo pipefail
+
+data_branch="${1:-contributors}"
+svg_path="${2:-contributors.svg}"
+
+git check-ref-format --branch "$data_branch" >/dev/null
+
+if [[ "$data_branch" == "main" || "$data_branch" == "dev" ]]; then
+ echo "Refusing to publish contributors onto $data_branch" >&2
+ exit 2
+fi
+
+case "$svg_path" in
+ ../*|*/../*|*/..)
+ echo "SVG path must not traverse upward: $svg_path" >&2
+ exit 2
+ ;;
+esac
+
+if [[ ! -f "$svg_path" ]]; then
+ echo "Generated contributors SVG is missing: $svg_path" >&2
+ exit 2
+fi
+
+if ! head -n 5 -- "$svg_path" | grep -q '<svg'; then
+ echo "Refusing to publish a file that is not an SVG: $svg_path" >&2
+ exit 2
+fi
+
+temp_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
+snapshot="$(mktemp "${temp_root%/}/archify-contributors.XXXXXX.svg")"
+cp -- "$svg_path" "$snapshot"
+
+if git ls-remote --exit-code --heads origin "refs/heads/$data_branch" >/dev/null 2>&1; then
+ git fetch --no-tags origin "refs/heads/$data_branch:refs/remotes/origin/$data_branch"
+ git switch --detach "refs/remotes/origin/$data_branch"
+else
+ git switch --orphan "$data_branch"
+fi
+
+# Keep the data branch to the generated wall so a fast-forward refresh stays linear.
+git rm -r -q --ignore-unmatch .
+cp -- "$snapshot" contributors.svg
+git add -f -- contributors.svg
+
+if git diff --cached --quiet; then
+ echo "Contributors wall is unchanged."
+ exit 0
+fi
+
+git -c user.name="github-actions[bot]" \
+ -c user.email="github-actions[bot]@users.noreply.github.com" \
+ commit -m "${CONTRIBUTORS_COMMIT_MESSAGE:-chore: update contributors wall}"
+git push origin "HEAD:refs/heads/$data_branch"
diff --git a/test/contributors-svg.test.mjs b/test/contributors-svg.test.mjs
new file mode 100644
index 00000000..9eb810fe
--- /dev/null
+++ b/test/contributors-svg.test.mjs
@@ -0,0 +1,282 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { execFileSync, spawnSync } from 'node:child_process';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import {
+ avatarMediaType,
+ buildContributorsSvg,
+ displayLogin,
+ fetchAvatarDataUri,
+ fetchContributors,
+ isBotContributor,
+ renderContributorsSvg,
+} from '../scripts/generate-contributors-svg.mjs';
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const publisher = path.join(repoRoot, 'scripts', 'publish-contributors-svg.sh');
+const png = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
+ 'base64',
+);
+const dataUri = `data:image/png;base64,${png.toString('base64')}`;
+
+function person(login, contributions, avatar = dataUri) {
+ return { login, contributions, dataUri: avatar };
+}
+
+function rowCounts(svg) {
+ const counts = new Map();
+ for (const match of svg.matchAll(/transform="translate\([0-9.]+ ([0-9.]+)\)"/g)) {
+ counts.set(match[1], (counts.get(match[1]) || 0) + 1);
+ }
+ return [...counts.values()];
+}
+
+function jsonResponse(body, { link, status = 200 } = {}) {
+ const headers = { 'content-type': 'application/json' };
+ if (link) headers.link = link;
+ return new Response(JSON.stringify(body), { status, headers });
+}
+
+test('bot accounts stay off the wall and human logins stay on it', () => {
+ assert.equal(isBotContributor({ login: 'github-actions[bot]', type: 'Bot' }), true);
+ assert.equal(isBotContributor({ login: 'dependabot[bot]', type: 'Bot' }), true);
+ assert.equal(isBotContributor({ login: 'claude', type: 'User' }), true);
+ assert.equal(isBotContributor({ login: 'Claude', type: 'User' }), true);
+ assert.equal(isBotContributor({ login: 'renovate[bot]', type: 'Bot' }), true);
+ assert.equal(isBotContributor({ login: 'custom-release[bot]', type: 'User' }), true);
+ assert.equal(isBotContributor({ login: 'some-app', type: 'Bot' }), true);
+ assert.equal(isBotContributor({ login: 'claudette', type: 'User' }), false);
+ assert.equal(isBotContributor({ login: 'robotics', type: 'User' }), false);
+ assert.equal(isBotContributor({ login: 'ada', type: 'User' }), false);
+});
+
+test('the wall is a 1000px grid of eight circular inline avatars', () => {
+ const longLogin = 'a'.repeat(39);
+ const people = Array.from({ length: 9 }, (_, index) => person(index === 8 ? longLogin : `user${index}`, 9 - index));
+ const svg = renderContributorsSvg(people);
+ assert.match(svg, /<svg[^>]*\swidth="1000"/);
+ assert.deepEqual(rowCounts(svg), [8, 1]);
+ assert.equal([...svg.matchAll(/<image\b[^>]*width="72"[^>]*height="72"/g)].length, 9);
+ assert.equal([...svg.matchAll(/<clipPath id="archify-contributor-\d+"><circle[^>]*r="36"/g)].length, 9);
+ assert.equal([...svg.matchAll(/clip-path="url\(#archify-contributor-\d+\)"/g)].length, 9);
+ assert.equal([...svg.matchAll(/data:image\/png;base64,/g)].length, 9);
+ assert.match(svg, /prefers-color-scheme:\s*dark/);
+ assert.match(svg, /\.name \{ fill: #24292f;/);
+ assert.match(svg, /fill: #f0f6fc;/);
+ assert.match(svg, new RegExp(`<title>${longLogin}</title>`));
+ assert.match(svg, new RegExp(`<text class="name"[^>]*>${displayLogin(longLogin)}</text>`));
+ assert.equal([...svg.matchAll(new RegExp(longLogin, 'g'))].length, 1);
+ assert.throws(() => renderContributorsSvg([]), /No human contributors/);
+ assert.throws(() => renderContributorsSvg([person('ada', 1, 'https://example.test/a.png')]), /inline avatar/);
+});
+
+test('contributor fetching keeps humans, follows GitHub pagination, and refuses other hosts', async () => {
+ const calls = [];
+ const fetchImpl = async (url) => {
+ calls.push(String(url));
+ if (String(url).includes('page=2')) {
+ return jsonResponse([
+ { login: 'ada', type: 'User', contributions: 4, avatar_url: 'https://avatars.githubusercontent.com/u/3' },
+ { login: 'grace', type: 'User', contributions: 4, avatar_url: 'https://avatars.githubusercontent.com/u/4' },
+ ]);
+ }
+ return jsonResponse([
+ { login: 'github-actions[bot]', type: 'Bot', contributions: 90, avatar_url: 'https://avatars.githubusercontent.com/u/1' },
+ { login: 'claude', type: 'User', contributions: 20, avatar_url: 'https://avatars.githubusercontent.com/u/2' },
+ { login: 'ada', type: 'User', contributions: 4, avatar_url: 'https://avatars.githubusercontent.com/u/3' },
+ { login: 'linus', type: 'User', contributions: 2, avatar_url: 'https://avatars.githubusercontent.com/u/5' },
+ ], {
+ link: '<https://api.github.com/repos/tt-a1i/archify/contributors?per_page=100&page=2>; rel="next"',
+ });
+ };
+
+ const people = await fetchContributors({ repo: 'tt-a1i/archify', fetchImpl });
+ assert.deepEqual(people.map((person) => person.login), ['ada', 'grace', 'linus']);
+ assert.equal(calls.length, 2);
+
+ const hostile = async () => jsonResponse([], {
+ link: '<https://evil.example/contributors>; rel="next"',
+ });
+ await assert.rejects(
+ () => fetchContributors({ repo: 'tt-a1i/archify', fetchImpl: hostile }),
+ /api\.github\.com/,
+ );
+ await assert.rejects(
+ () => fetchContributors({
+ repo: 'tt-a1i/archify',
+ fetchImpl: async () => jsonResponse([{ login: 'dependabot[bot]', type: 'Bot', contributions: 1 }]),
+ }),
+ /No human contributors/,
+ );
+});
+
+test('avatar bytes are inlined only from GitHub image responses', async () => {
+ assert.equal(avatarMediaType(png, 'application/octet-stream'), 'image/png');
+ const svg = await buildContributorsSvg({
+ repo: 'tt-a1i/archify',
+ fetchImpl: async (url) => {
+ if (String(url).includes('/contributors')) {
+ return jsonResponse([
+ { login: 'ada', type: 'User', contributions: 2, avatar_url: 'https://avatars.githubusercontent.com/u/3?v=4' },
+ { login: 'claude', type: 'User', contributions: 9, avatar_url: 'https://avatars.githubusercontent.com/u/2' },
+ ]);
+ }
+ assert.match(String(url), /^https:\/\/avatars\.githubusercontent\.com\/u\/3\?/);
+ assert.match(String(url), /(?:\?|&)s=144(?:&|$)/);
+ return new Response(png, { status: 200, headers: { 'content-type': 'image/png' } });
+ },
+ });
+ assert.match(svg, /<title>ada<\/title>/);
+ assert.equal(svg.includes('claude'), false);
+ assert.match(svg, /data:image\/png;base64,/);
+});
+
+test('public avatars follow validated GitHub redirects without sending the API token', async () => {
+ const requests = [];
+ const data = await fetchAvatarDataUri({ login: 'ada', avatarUrl: 'https://github.com/ada.png' }, {
+ token: 'SYNTHETIC-CANARY',
+ fetchImpl: async (url, options) => {
+ requests.push(String(url));
+ assert.equal(new Headers(options.headers).has('authorization'), false);
+ assert.equal(options.redirect, 'manual');
+ if (requests.length === 1) return new Response(null, {
+ status: 302, headers: { location: 'https://avatars.githubusercontent.com/u/3' },
+ });
+ return new Response(png, { headers: { 'content-type': 'image/png' } });
+ },
+ });
+ assert.equal(data, dataUri);
+ assert.equal(requests.length, 2);
+ assert.equal(new URL(requests[1]).hostname, 'avatars.githubusercontent.com');
+});
+
+for (const location of ['https://other.example/avatar.png', 'http://avatars.githubusercontent.com/u/3']) {
+ test(`avatar redirects are refused before requesting ${location}`, async () => {
+ let requests = 0;
+ await assert.rejects(() => fetchAvatarDataUri({ login: 'ada', avatarUrl: 'https://github.com/ada.png' }, {
+ fetchImpl: async () => {
+ requests += 1;
+ return new Response(null, { status: 302, headers: { location } });
+ },
+ }), /Refusing avatar host/);
+ assert.equal(requests, 1, 'the rejected target must never receive a request');
+ });
+}
+
+test('avatar redirect loops stop after a bounded number of requests', async () => {
+ let requests = 0;
+ await assert.rejects(() => fetchAvatarDataUri({ login: 'ada', avatarUrl: 'https://github.com/ada.png' }, {
+ fetchImpl: async () => {
+ requests += 1;
+ return new Response(null, { status: 302, headers: { location: '/ada.png' } });
+ },
+ }), /Too many avatar redirects/);
+ assert.equal(requests, 6);
+});
+
+function git(cwd, args) {
+ return execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();
+}
+
+test('contributors publishing fast-forwards a data branch and refuses main or dev', () => {
+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-contributors-'));
+ const remote = path.join(fixture, 'remote.git');
+ const firstCheckout = path.join(fixture, 'first');
+ const secondCheckout = path.join(fixture, 'second');
+ const shell = 'bash';
+ const writeSvg = (file, label) => fs.writeFileSync(file, `<svg xmlns="http://www.w3.org/2000/svg"><title>${label}</title></svg>\n`);
+
+ try {
+ git(fixture, ['init', '--bare', remote]);
+ git(fixture, ['--git-dir', remote, 'config', 'receive.denyNonFastForwards', 'true']);
+ git(fixture, ['--git-dir', remote, 'config', 'receive.denyDeletes', 'true']);
+
+ fs.mkdirSync(firstCheckout);
+ git(firstCheckout, ['init', '-b', 'main']);
+ git(firstCheckout, ['config', 'user.name', 'Fixture']);
+ git(firstCheckout, ['config', 'user.email', '[email protected]']);
+ fs.writeFileSync(path.join(firstCheckout, 'README.md'), 'fixture\n');
+ git(firstCheckout, ['add', 'README.md']);
+ git(firstCheckout, ['commit', '-m', 'seed']);
+ git(firstCheckout, ['remote', 'add', 'origin', remote]);
+ git(firstCheckout, ['push', '-u', 'origin', 'main']);
+ const mainCommit = git(firstCheckout, ['rev-parse', 'HEAD']);
+
+ const firstSvg = path.join(fixture, 'wall-1.svg');
+ const sameSvg = path.join(fixture, 'wall-1-copy.svg');
+ writeSvg(firstSvg, 'v1');
+ writeSvg(sameSvg, 'v1');
+ const firstTemp = path.join(fixture, 'run-1');
+ fs.mkdirSync(firstTemp);
+ execFileSync(shell, [publisher, 'contributors', firstSvg], {
+ cwd: firstCheckout,
+ env: { ...process.env, RUNNER_TEMP: firstTemp },
+ });
+ const firstCommit = git(fixture, ['--git-dir', remote, 'rev-parse', 'refs/heads/contributors']);
+ assert.equal(git(fixture, ['--git-dir', remote, 'rev-parse', 'refs/heads/main']), mainCommit);
+
+ git(fixture, ['clone', '--branch', 'main', remote, secondCheckout]);
+ const sameTemp = path.join(fixture, 'run-same');
+ fs.mkdirSync(sameTemp);
+ const unchanged = spawnSync(shell, [publisher, 'contributors', sameSvg], {
+ cwd: secondCheckout,
+ env: { ...process.env, RUNNER_TEMP: sameTemp },
+ encoding: 'utf8',
+ });
+ assert.equal(unchanged.status, 0, unchanged.stderr);
+ assert.equal(git(fixture, ['--git-dir', remote, 'rev-parse', 'refs/heads/contributors']), firstCommit);
+ assert.match(unchanged.stdout, /unchanged/);
+
+ const secondSvg = path.join(fixture, 'wall-2.svg');
+ writeSvg(secondSvg, 'v2');
+ const secondTemp = path.join(fixture, 'run-2');
+ fs.mkdirSync(secondTemp);
+ execFileSync(shell, [publisher, 'contributors', secondSvg], {
+ cwd: secondCheckout,
+ env: { ...process.env, RUNNER_TEMP: secondTemp },
+ });
+ const secondCommit = git(fixture, ['--git-dir', remote, 'rev-parse', 'refs/heads/contributors']);
+ assert.notEqual(secondCommit, firstCommit);
+ git(fixture, ['--git-dir', remote, 'merge-base', '--is-ancestor', firstCommit, secondCommit]);
+ assert.deepEqual(
+ git(fixture, ['--git-dir', remote, 'ls-tree', '-r', '--name-only', secondCommit]).split('\n'),
+ ['contributors.svg'],
+ );
+ assert.match(
+ git(fixture, ['--git-dir', remote, 'show', `${secondCommit}:contributors.svg`]),
+ /v2/,
+ );
+ assert.equal(git(fixture, ['--git-dir', remote, 'rev-parse', 'refs/heads/main']), mainCommit);
+
+ for (const branch of ['main', 'dev']) {
+ const refused = spawnSync(shell, [publisher, branch, secondSvg], {
+ cwd: secondCheckout,
+ encoding: 'utf8',
+ });
+ assert.notEqual(refused.status, 0, branch);
+ assert.match(refused.stderr, new RegExp(branch));
+ }
+ } finally {
+ fs.rmSync(fixture, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
+ }
+});
+
+test('the contributors workflow publishes the data branch instead of main or dev', () => {
+ const workflow = fs.readFileSync(path.join(repoRoot, '.github', 'workflows', 'contributors.yml'), 'utf8');
+ assert.match(workflow, /^name: Contributors/m);
+ assert.match(workflow, /workflow_dispatch:/);
+ assert.match(workflow, /schedule:/);
+ assert.match(workflow, /cron: '15 5 \* \* 1'/);
+ assert.match(workflow, /permissions:\n contents: write/);
+ assert.match(workflow, /actions\/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09/);
+ assert.match(workflow, /actions\/setup-node@a0853c24544627f65ddf259abe73b1d18a591444/);
+ assert.match(workflow, /node-version: 22/);
+ assert.match(workflow, /node scripts\/generate-contributors-svg\.mjs --out "\$RUNNER_TEMP\/contributors\.svg"/);
+ assert.match(workflow, /bash scripts\/publish-contributors-svg\.sh contributors "\$RUNNER_TEMP\/contributors\.svg"/);
+ assert.doesNotMatch(workflow, /branches:\s*\[(?:main|dev)/);
+ assert.doesNotMatch(workflow, /git-auto-commit-action|git commit|git push/);
+});