Skip to content

armgit / pibot

Public Imported from GitHub
0

Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.

Align README credits with GitHub Contributors

leen.zhou152425febf89
diff --git a/.github/workflows/readme-contributors.yml b/.github/workflows/readme-contributors.yml
index 81edd66..8f63eec 100644
--- a/.github/workflows/readme-contributors.yml
+++ b/.github/workflows/readme-contributors.yml
@@ -3,6 +3,9 @@ name: README contributors
on:
push:
branches: [main]
+ schedule:
+ # GitHub can serve cached contributor data for a few hours after a push.
+ - cron: '17 */6 * * *'
workflow_dispatch:
permissions:
@@ -27,6 +30,8 @@ jobs:
with:
node-version-file: .nvmrc
- name: Refresh the English README
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
diff --git a/README.md b/README.md
index 9784837..39df2f6 100644
--- a/README.md
+++ b/README.md
@@ -110,11 +110,10 @@ Thank you to everyone who has contributed to Pi Bot. See the
[contribution activity](https://github.com/w01fb0ss/PiBot/graphs/contributors) on GitHub.
<!-- CONTRIBUTORS:START -->
-- agooll
-- Ikko Eltociear Ashimine
-- JQuery
-- juemimgcd
-- leen.zhou
+- [@w01fb0ss](https://github.com/w01fb0ss)
+- [@juemimgcd](https://github.com/juemimgcd)
+- [@eltociear](https://github.com/eltociear)
+- [@agooll](https://github.com/agooll)
<!-- CONTRIBUTORS:END -->
## Star History
diff --git a/tools/dev/update-readme-contributors.ts b/tools/dev/update-readme-contributors.ts
index 52bbe8b..71076fe 100644
--- a/tools/dev/update-readme-contributors.ts
+++ b/tools/dev/update-readme-contributors.ts
@@ -16,30 +16,54 @@ if (
throw new Error("Expected one contributor section in the English README");
}
-// The mailmap canonicalizes aliases. Only names, never commit email addresses, go into the README.
-const authors = execFileSync(
- "git",
- ["log", "--no-merges", "--encoding=UTF-8", "--format=%aN", "HEAD"],
- {
- encoding: "utf8",
- },
-);
-const names = [
- ...new Set(
- authors
- .split("\n")
- .map((name) => name.replace(/[\p{Cc}\p{Cf}]/gu, "").trim())
- .filter((name) => name && !name.toLowerCase().endsWith("[bot]")),
- ),
-].sort((left, right) => left.localeCompare(right, "en"));
-if (names.length === 0) throw new Error("No human commit authors found");
+function fetchContributors(): unknown {
+ let body: string;
+ try {
+ body = execFileSync(
+ "gh",
+ [
+ "api",
+ "--hostname",
+ "github.com",
+ "--paginate",
+ "--slurp",
+ "repos/w01fb0ss/PiBot/contributors?per_page=100",
+ ],
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 60_000 },
+ );
+ } catch {
+ throw new Error("GitHub contributor request failed");
+ }
+ try {
+ return JSON.parse(body) as unknown;
+ } catch {
+ throw new Error("Invalid GitHub contributor response");
+ }
+}
+
+const pages = fetchContributors();
+const invalidResponse = () => new Error("Invalid GitHub contributor response");
+if (!Array.isArray(pages) || pages.length === 0) throw invalidResponse();
+const logins = new Map<string, string>();
+const githubLogin = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;
+for (const page of pages) {
+ if (!Array.isArray(page) || page.length === 0) throw invalidResponse();
+ for (const contributor of page as unknown[]) {
+ if (typeof contributor !== "object" || !contributor || !("type" in contributor))
+ throw invalidResponse();
+ if (contributor.type === "Anonymous") continue;
+ if (!("login" in contributor) || typeof contributor.login !== "string") throw invalidResponse();
+ if (contributor.type === "Bot") continue;
+ if (contributor.type !== "User" || !githubLogin.test(contributor.login))
+ throw invalidResponse();
+ const key = contributor.login.toLowerCase();
+ if (!logins.has(key)) logins.set(key, contributor.login);
+ }
+}
+if (logins.size === 0) throw new Error("No linked GitHub contributors found");
-// Encode Markdown and HTML syntax from the commit author field as text.
-const list = names
- .map((name) => {
- const label = name.replace(/[^\p{L}\p{M}\p{N} .-]/gu, (char) => `&#${char.codePointAt(0)};`);
- return `- ${label}`;
- })
+const list = [...logins.values()]
+ .map((login) => `- [@${login}](https://github.com/${login})`)
.join("\n");
const updated = readme.slice(0, from + start.length) + list + readme.slice(to);
if (updated !== readme) writeFileSync(path, updated);