Skip to content

Commit e026b8d

Browse files
committed
feat: fetch real GitHub social preview at build time
- build-index.ts scrapes og:image from each repo's GitHub page - Stores as social_preview in index.json - Custom social previews (repository-images.githubusercontent.com) preserved - Falls back to auto-generated opengraph.githubassets.com if no custom set
1 parent 26218fa commit e026b8d

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

index.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
],
2525
"icon": null,
2626
"banner": null,
27+
"social_preview": "https://opengraph.githubassets.com/fb12cdd7813bedc8e01dac838036f1878b14aeaccb5b00430bc015bc56bbc69e/shreyas-lyzr/agent-designer",
2728
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__agent-designer/README.md",
2829
"added_at": "2026-03-01"
2930
},
@@ -50,6 +51,7 @@
5051
],
5152
"icon": null,
5253
"banner": null,
54+
"social_preview": "https://repository-images.githubusercontent.com/1164987139/49ba99c6-5916-4bdd-8d28-dde492f22827",
5355
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__architect/README.md",
5456
"added_at": "2026-03-01"
5557
},
@@ -78,10 +80,11 @@
7880
],
7981
"icon": null,
8082
"banner": null,
83+
"social_preview": "https://opengraph.githubassets.com/f7d8761974c8926820b7d30a10eaa92595870d0c2c848b89cec7e0ca57b5f355/shreyas-lyzr/quant-sim",
8184
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__quant-sim/README.md",
8285
"added_at": "2026-03-01"
8386
}
8487
],
8588
"total": 3,
86-
"generated_at": "2026-03-01T14:22:43.997Z"
89+
"generated_at": "2026-03-01T16:19:41.736Z"
8790
}

scripts/build-index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface AgentMetadata {
3838
interface IndexEntry extends Omit<AgentMetadata, "icon" | "banner"> {
3939
icon: string | null;
4040
banner: string | null;
41+
social_preview: string | null;
4142
readme: string;
4243
added_at: string;
4344
}
@@ -63,6 +64,22 @@ function getFirstCommitDate(folderPath: string): string {
6364
return new Date().toISOString().split("T")[0];
6465
}
6566

67+
function fetchSocialPreview(repoUrl: string): string | null {
68+
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+
}
77+
} catch {
78+
// fallback
79+
}
80+
return null;
81+
}
82+
6683
function buildIndex(): Index {
6784
const agents: IndexEntry[] = [];
6885

@@ -97,6 +114,9 @@ function buildIndex(): Index {
97114
const hasBanner = metadata.banner === true && existsSync(join(folderPath, "banner.png"));
98115
const addedAt = getFirstCommitDate(folderPath);
99116

117+
console.log(` Fetching social preview for ${metadata.repository}...`);
118+
const socialPreview = fetchSocialPreview(metadata.repository);
119+
100120
const entry: IndexEntry = {
101121
name: metadata.name,
102122
author: metadata.author,
@@ -110,6 +130,7 @@ function buildIndex(): Index {
110130
adapters: metadata.adapters,
111131
icon: hasIcon ? `${RAW_BASE}/agents/${folder}/icon.png` : null,
112132
banner: hasBanner ? `${RAW_BASE}/agents/${folder}/banner.png` : null,
133+
social_preview: socialPreview,
113134
readme: `${RAW_BASE}/agents/${folder}/README.md`,
114135
added_at: addedAt,
115136
};

site/public/index.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
],
2525
"icon": null,
2626
"banner": null,
27+
"social_preview": "https://opengraph.githubassets.com/fb12cdd7813bedc8e01dac838036f1878b14aeaccb5b00430bc015bc56bbc69e/shreyas-lyzr/agent-designer",
2728
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__agent-designer/README.md",
2829
"added_at": "2026-03-01"
2930
},
@@ -50,6 +51,7 @@
5051
],
5152
"icon": null,
5253
"banner": null,
54+
"social_preview": "https://repository-images.githubusercontent.com/1164987139/49ba99c6-5916-4bdd-8d28-dde492f22827",
5355
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__architect/README.md",
5456
"added_at": "2026-03-01"
5557
},
@@ -78,10 +80,11 @@
7880
],
7981
"icon": null,
8082
"banner": null,
83+
"social_preview": "https://opengraph.githubassets.com/f7d8761974c8926820b7d30a10eaa92595870d0c2c848b89cec7e0ca57b5f355/shreyas-lyzr/quant-sim",
8184
"readme": "https://raw.githubusercontent.com/open-gitagent/registry/main/agents/shreyas-lyzr__quant-sim/README.md",
8285
"added_at": "2026-03-01"
8386
}
8487
],
8588
"total": 3,
86-
"generated_at": "2026-03-01T14:11:09.313Z"
89+
"generated_at": "2026-03-01T16:19:41.736Z"
8790
}

0 commit comments

Comments
 (0)