Skip to content

Commit dfc1e28

Browse files
committed
feat: fetch GitHub stats (stars, forks, issues, avatar) at build time
- Replaces social_preview with github stats object - API call to api.github.com/repos for each agent - Stores stars, forks, issues, language, avatar_url, description
1 parent 7d00a25 commit dfc1e28

3 files changed

Lines changed: 81 additions & 25 deletions

File tree

index.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
],
2525
"icon": null,
2626
"banner": null,
27-
"social_preview": "https://opengraph.githubassets.com/fb12cdd7813bedc8e01dac838036f1878b14aeaccb5b00430bc015bc56bbc69e/shreyas-lyzr/agent-designer",
27+
"github": {
28+
"stars": 1,
29+
"forks": 0,
30+
"issues": 0,
31+
"language": null,
32+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
33+
"description": "Meta-agent for designing AI agent action spaces — based on lessons from building Claude Code"
34+
},
2835
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__agent-designer/README.md",
2936
"added_at": "2026-03-01"
3037
},
@@ -51,7 +58,14 @@
5158
],
5259
"icon": null,
5360
"banner": null,
54-
"social_preview": "https://repository-images.githubusercontent.com/1164987139/49ba99c6-5916-4bdd-8d28-dde492f22827",
61+
"github": {
62+
"stars": 2,
63+
"forks": 1,
64+
"issues": 0,
65+
"language": null,
66+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
67+
"description": "The official gitagent assistant — an AI agent that helps you build, run, and manage AI agents with gitagent"
68+
},
5569
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__architect/README.md",
5670
"added_at": "2026-03-01"
5771
},
@@ -80,11 +94,18 @@
8094
],
8195
"icon": null,
8296
"banner": null,
83-
"social_preview": "https://opengraph.githubassets.com/f7d8761974c8926820b7d30a10eaa92595870d0c2c848b89cec7e0ca57b5f355/shreyas-lyzr/quant-sim",
97+
"github": {
98+
"stars": 0,
99+
"forks": 0,
100+
"issues": 0,
101+
"language": null,
102+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
103+
"description": "Institutional-grade prediction market simulation engine — Monte Carlo, importance sampling, particle filters, copula dependency modeling, and agent-based market microstructure"
104+
},
84105
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__quant-sim/README.md",
85106
"added_at": "2026-03-01"
86107
}
87108
],
88109
"total": 3,
89-
"generated_at": "2026-03-01T16:20:03.395Z"
110+
"generated_at": "2026-03-01T16:31:43.040Z"
90111
}

scripts/build-index.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Usage: npx tsx scripts/build-index.ts
77
*
88
* Reads each agents/<author>__<name>/metadata.json, enriches with
9-
* icon URL, readme URL, and added_at date, then writes index.json.
9+
* icon URL, readme URL, added_at date, and GitHub repo stats.
1010
*/
1111

1212
import { readFileSync, writeFileSync, readdirSync, existsSync, statSync } from "fs";
@@ -35,10 +35,19 @@ interface AgentMetadata {
3535
banner?: boolean;
3636
}
3737

38+
interface GitHubStats {
39+
stars: number;
40+
forks: number;
41+
issues: number;
42+
language: string | null;
43+
avatar: string;
44+
description: string | null;
45+
}
46+
3847
interface IndexEntry extends Omit<AgentMetadata, "icon" | "banner"> {
3948
icon: string | null;
4049
banner: string | null;
41-
social_preview: string | null;
50+
github: GitHubStats | null;
4251
readme: string;
4352
added_at: string;
4453
}
@@ -64,20 +73,25 @@ function getFirstCommitDate(folderPath: string): string {
6473
return new Date().toISOString().split("T")[0];
6574
}
6675

67-
function fetchSocialPreview(repoUrl: string): string | null {
76+
function fetchGitHubStats(repoUrl: string): GitHubStats | null {
77+
const repoPath = repoUrl.replace("https://github.com/", "");
6878
try {
69-
const html = execSync(`curl -sL "${repoUrl}"`, {
70-
encoding: "utf-8",
71-
timeout: 15_000,
72-
});
73-
const match = html.match(/property="og:image"\s+content="([^"]+)"/);
74-
if (match?.[1] && !match[1].includes("avatars.githubusercontent.com")) {
75-
return match[1];
76-
}
79+
const json = execSync(
80+
`curl -sL "https://api.github.com/repos/${repoPath}"`,
81+
{ encoding: "utf-8", timeout: 15_000 }
82+
);
83+
const data = JSON.parse(json);
84+
return {
85+
stars: data.stargazers_count ?? 0,
86+
forks: data.forks_count ?? 0,
87+
issues: data.open_issues_count ?? 0,
88+
language: data.language ?? null,
89+
avatar: data.owner?.avatar_url ?? "",
90+
description: data.description ?? null,
91+
};
7792
} catch {
78-
// fallback
93+
return null;
7994
}
80-
return null;
8195
}
8296

8397
function buildIndex(): Index {
@@ -114,8 +128,8 @@ function buildIndex(): Index {
114128
const hasBanner = metadata.banner === true && existsSync(join(folderPath, "banner.png"));
115129
const addedAt = getFirstCommitDate(folderPath);
116130

117-
console.log(` Fetching social preview for ${metadata.repository}...`);
118-
const socialPreview = fetchSocialPreview(metadata.repository);
131+
console.log(` Fetching GitHub stats for ${metadata.repository}...`);
132+
const github = fetchGitHubStats(metadata.repository);
119133

120134
const entry: IndexEntry = {
121135
name: metadata.name,
@@ -130,7 +144,7 @@ function buildIndex(): Index {
130144
adapters: metadata.adapters,
131145
icon: hasIcon ? `${RAW_BASE}/agents/${folder}/icon.png` : null,
132146
banner: hasBanner ? `${RAW_BASE}/agents/${folder}/banner.png` : null,
133-
social_preview: socialPreview,
147+
github,
134148
readme: `${RAW_BASE}/agents/${folder}/README.md`,
135149
added_at: addedAt,
136150
};
@@ -140,7 +154,7 @@ function buildIndex(): Index {
140154
}
141155

142156
agents.push(entry);
143-
console.log(` + ${metadata.author}/${metadata.name} (${metadata.category})`);
157+
console.log(` + ${metadata.author}/${metadata.name} (stars:${github?.stars ?? '?'} forks:${github?.forks ?? '?'})`);
144158
}
145159

146160
// Sort by name

site/public/index.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
],
2525
"icon": null,
2626
"banner": null,
27-
"social_preview": "https://opengraph.githubassets.com/fb12cdd7813bedc8e01dac838036f1878b14aeaccb5b00430bc015bc56bbc69e/shreyas-lyzr/agent-designer",
27+
"github": {
28+
"stars": 1,
29+
"forks": 0,
30+
"issues": 0,
31+
"language": null,
32+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
33+
"description": "Meta-agent for designing AI agent action spaces — based on lessons from building Claude Code"
34+
},
2835
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__agent-designer/README.md",
2936
"added_at": "2026-03-01"
3037
},
@@ -51,7 +58,14 @@
5158
],
5259
"icon": null,
5360
"banner": null,
54-
"social_preview": "https://repository-images.githubusercontent.com/1164987139/49ba99c6-5916-4bdd-8d28-dde492f22827",
61+
"github": {
62+
"stars": 2,
63+
"forks": 1,
64+
"issues": 0,
65+
"language": null,
66+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
67+
"description": "The official gitagent assistant — an AI agent that helps you build, run, and manage AI agents with gitagent"
68+
},
5569
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__architect/README.md",
5670
"added_at": "2026-03-01"
5771
},
@@ -80,11 +94,18 @@
8094
],
8195
"icon": null,
8296
"banner": null,
83-
"social_preview": "https://opengraph.githubassets.com/f7d8761974c8926820b7d30a10eaa92595870d0c2c848b89cec7e0ca57b5f355/shreyas-lyzr/quant-sim",
97+
"github": {
98+
"stars": 0,
99+
"forks": 0,
100+
"issues": 0,
101+
"language": null,
102+
"avatar": "https://avatars.githubusercontent.com/u/141219160?v=4",
103+
"description": "Institutional-grade prediction market simulation engine — Monte Carlo, importance sampling, particle filters, copula dependency modeling, and agent-based market microstructure"
104+
},
84105
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__quant-sim/README.md",
85106
"added_at": "2026-03-01"
86107
}
87108
],
88109
"total": 3,
89-
"generated_at": "2026-03-01T16:19:41.736Z"
110+
"generated_at": "2026-03-01T16:31:43.040Z"
90111
}

0 commit comments

Comments
 (0)