forked from greynewell/evaldriven.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
384 lines (333 loc) · 13.8 KB
/
build.py
File metadata and controls
384 lines (333 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#!/usr/bin/env python3
"""Build evaldriven.org: README.md + stargazers → static HTML site."""
import json
import re
import subprocess
import sys
import html as html_mod
from pathlib import Path
from datetime import datetime
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).parent
OUTPUT = ROOT / "output"
README = ROOT / "README.md"
# Site metadata (not in README so GitHub renders it clean)
SITE = {
"title": "Eval-Driven Development",
"description": "A manifesto for evaluation-driven AI development. Why every AI system needs deterministic, automated evaluation as a first-class engineering practice.",
"author": "Grey Newell",
"base_url": "https://evaldriven.org",
"repo": "greynewell/evaldriven.org",
"keywords": [
"eval-driven development", "AI evaluation", "LLM evaluation",
"model evaluation", "evaluation engineering", "CI/CD for LLMs",
"deterministic testing", "AI quality assurance",
],
}
def md_to_html(md):
"""Convert markdown to HTML."""
lines = md.split("\n")
out = []
in_ul = False
in_ol = False
in_code = False
code_lines = []
for line in lines:
if line.startswith("```"):
if in_code:
out.append("<pre><code>" + html_mod.escape("\n".join(code_lines)) + "</code></pre>")
code_lines = []
in_code = False
else:
in_code = True
continue
if in_code:
code_lines.append(line)
continue
# Close lists if needed
if in_ul and not re.match(r"^[-*] ", line):
out.append("</ul>")
in_ul = False
if in_ol and not re.match(r"^\d+\. ", line):
out.append("</ol>")
in_ol = False
# Headings
m = re.match(r"^(#{1,6})\s+(.*)", line)
if m:
level = len(m.group(1))
text = m.group(2)
slug = re.sub(r"[^a-z0-9]+", "-", text.lower()).strip("-")
out.append(f'<h{level} id="{slug}">{inline(text)}</h{level}>')
continue
# Horizontal rule
if re.match(r"^---+\s*$", line):
out.append("<hr>")
continue
# Unordered list items
m = re.match(r"^[-*] (.*)", line)
if m:
if not in_ul:
out.append("<ul>")
in_ul = True
out.append(f"<li>{inline(m.group(1))}</li>")
continue
# Ordered list items
m = re.match(r"^\d+\. (.*)", line)
if m:
if not in_ol:
out.append("<ol>")
in_ol = True
out.append(f"<li>{inline(m.group(1))}</li>")
continue
# Blockquote
if line.startswith("> "):
out.append(f"<blockquote><p>{inline(line[2:])}</p></blockquote>")
continue
# Empty line
if not line.strip():
out.append("")
continue
# Paragraph
out.append(f"<p>{inline(line)}</p>")
if in_ul:
out.append("</ul>")
if in_ol:
out.append("</ol>")
return "\n".join(out)
def inline(text):
"""Process inline markdown formatting."""
text = re.sub(r"\*\*(.+?)\*\*", r"<strong>\1</strong>", text)
text = re.sub(r"\*(.+?)\*", r"<em>\1</em>", text)
text = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r'<a href="\2">\1</a>', text)
text = re.sub(r"`([^`]+)`", r"<code>\1</code>", text)
return text
def fetch_stargazers():
"""Fetch all stargazers via gh CLI."""
users = []
page = 1
while True:
try:
result = subprocess.run(
["gh", "api",
f"repos/{SITE['repo']}/stargazers?per_page=100&page={page}",
"--jq", ".[].login"],
capture_output=True, text=True, timeout=30
)
batch = result.stdout.strip()
if not batch:
break
users.extend(batch.split("\n"))
page += 1
except Exception:
break
return users
def fetch_repo_stats():
"""Fetch fork and watcher counts from the repo."""
try:
result = subprocess.run(
["gh", "api", f"repos/{SITE['repo']}",
"--jq", "[.forks_count, .subscribers_count] | @tsv"],
capture_output=True, text=True, timeout=30,
)
parts = result.stdout.strip().split("\t")
return {"forks": int(parts[0]), "watchers": int(parts[1])}
except Exception:
return {"forks": 0, "watchers": 0}
def build_signatories_html(users, stats):
"""Build the signatories section."""
repo_url = f"https://github.com/{SITE['repo']}"
h = '<h2 id="signatories">Signatories</h2>\n'
h += f'<p><a href="{repo_url}">Star this repo</a> to sign the manifesto.'
h += f' <a href="{repo_url}/fork">Fork it</a> to create your own.</p>\n'
if users:
h += '<ul style="columns: 2; column-gap: 1.5rem; list-style: none; padding-left: 0;">\n'
for login in users:
if login.strip():
h += f'<li><a href="https://github.com/{login}">{login}</a></li>\n'
h += "</ul>\n"
else:
h += "<p><em>Be the first to sign.</em></p>\n"
h += f'<p style="font-size: 0.8em; color: #777;">'
h += f'{stats["watchers"]} watching · {stats["forks"]} forks'
h += '</p>\n'
return h
def build_og_image(count):
"""Generate a 1200x630 OG image with the signatory count."""
W, H = 1200, 630
img = Image.new("RGB", (W, H), "#ffffff")
draw = ImageDraw.Draw(img)
# Use Courier/monospace to match the site aesthetic.
# DejaVu Sans Mono is available on Ubuntu runners; fall back to default.
def mono(size):
for name in ["DejaVuSansMono.ttf", "DejaVuSansMono-Bold.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf",
"Courier New.ttf", "cour.ttf"]:
try:
return ImageFont.truetype(name, size)
except OSError:
continue
return ImageFont.load_default(size)
def bold(size):
for name in ["DejaVuSansMono-Bold.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf",
"Courier New Bold.ttf", "courbd.ttf"]:
try:
return ImageFont.truetype(name, size)
except OSError:
continue
return mono(size)
# Border
draw.rectangle([20, 20, W - 21, H - 21], outline="#000000", width=3)
# Checkmark
check_font = mono(72)
draw.text((W // 2, 120), "\u2713", fill="#000000", font=check_font, anchor="mm")
# Title
title_font = bold(52)
draw.text((W // 2, 220), "EVAL-DRIVEN", fill="#000000", font=title_font, anchor="mm")
draw.text((W // 2, 285), "DEVELOPMENT", fill="#000000", font=title_font, anchor="mm")
# Divider
draw.line([(200, 330), (W - 200, 330)], fill="#000000", width=2)
# Subtitle
sub_font = mono(30)
draw.text((W // 2, 380), "A manifesto for evaluation-driven", fill="#333333", font=sub_font, anchor="mm")
draw.text((W // 2, 420), "AI development", fill="#333333", font=sub_font, anchor="mm")
# Count
count_font = bold(36)
draw.text((W // 2, 500), f"{count} signatories", fill="#000000", font=count_font, anchor="mm")
# URL
url_font = mono(22)
draw.text((W // 2, 565), "evaldriven.org", fill="#555555", font=url_font, anchor="mm")
path = OUTPUT / "og.png"
img.save(path, "PNG")
return path
def build_page(body_html, signatories_html):
"""Generate the full HTML page."""
title = SITE["title"]
desc = SITE["description"]
author = SITE["author"]
base = SITE["base_url"]
now = datetime.now().strftime("%Y-%m-%d")
json_ld = json.dumps({
"@context": "https://schema.org",
"@type": "Article",
"headline": title,
"description": desc,
"author": {"@type": "Person", "name": author, "url": "https://greynewell.com"},
"publisher": {"@type": "Person", "name": author, "url": "https://greynewell.com"},
"url": base,
"datePublished": "2026-02-15",
"dateModified": now,
"mainEntityOfPage": {"@type": "WebPage", "@id": base},
"keywords": SITE["keywords"],
})
return f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
<meta name="description" content="{desc}">
<meta name="author" content="{author}">
<meta property="og:title" content="{title}">
<meta property="og:description" content="{desc}">
<meta property="og:url" content="{base}/">
<meta property="og:type" content="article">
<meta property="og:image" content="{base}/og.png">
<meta property="og:site_name" content="{title}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{title}">
<meta name="twitter:description" content="{desc}">
<meta name="twitter:image" content="{base}/og.png">
<link rel="canonical" href="{base}/">
<meta name="robots" content="index, follow">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ctext x='4' y='26' font-size='28' font-family='monospace'%3E%E2%9C%93%3C/text%3E%3C/svg%3E">
<script type="application/ld+json">{json_ld}</script>
<style>
*, *::before, *::after {{ margin: 0; padding: 0; box-sizing: border-box; }}
body {{ font-family: 'Courier New', Courier, monospace; max-width: 650px; margin: 40px auto; padding: 0 20px; line-height: 1.6; background: #fff; color: #111; font-size: 16px; }}
h1, h2, h3 {{ font-family: 'Courier New', Courier, monospace; font-weight: 700; color: #000; }}
h1 {{ font-size: 1.5rem; margin: 0 0 1rem; text-transform: uppercase; letter-spacing: 0.05em; }}
h2 {{ font-size: 1.125rem; margin: 2rem 0 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid #000; padding-bottom: 0.25rem; }}
h3 {{ font-size: 1rem; margin: 1.5rem 0 0.5rem; }}
p {{ margin: 0.75rem 0; }}
ul, ol {{ padding-left: 1.5rem; margin: 0.75rem 0; }}
li {{ margin: 0.3rem 0; }}
a {{ color: #111; text-decoration: underline; }}
a:hover {{ color: #555; }}
code {{ font-family: 'Courier New', Courier, monospace; font-size: 0.9em; background: #f5f5f5; padding: 0.1em 0.3em; }}
pre {{ background: #f5f5f5; border: 1px solid #ddd; padding: 1rem; overflow-x: auto; margin: 1rem 0; line-height: 1.4; }}
pre code {{ background: none; padding: 0; font-size: 0.875rem; }}
blockquote {{ border-left: 3px solid #111; padding: 0.5rem 1rem; margin: 1rem 0; color: #333; }}
hr {{ border: none; border-top: 1px solid #111; margin: 2rem 0; }}
header {{ display: flex; align-items: baseline; justify-content: space-between; padding: 0 0 1rem; border-bottom: 2px solid #000; margin-bottom: 2rem; }}
header .brand {{ font-weight: 700; font-size: 0.875rem; color: #000; text-decoration: none; text-transform: uppercase; letter-spacing: 0.08em; }}
header nav {{ display: flex; gap: 1rem; }}
header nav a {{ font-size: 0.8125rem; color: #555; text-decoration: none; text-transform: uppercase; letter-spacing: 0.05em; }}
header nav a:hover {{ color: #000; }}
footer {{ margin-top: 3rem; padding-top: 1rem; border-top: 2px solid #000; text-align: center; font-size: 0.75rem; color: #777; }}
footer a {{ color: #555; text-decoration: none; text-transform: uppercase; letter-spacing: 0.05em; }}
footer a:hover {{ color: #000; }}
@media (max-width: 640px) {{ body {{ margin: 20px auto; padding: 0 15px; }} header {{ flex-direction: column; gap: 0.5rem; }} footer {{ flex-direction: column; }} }}
</style>
</head>
<body>
<header>
<a href="/" class="brand">evaldriven.org</a>
<nav>
<a href="https://github.com/{SITE['repo']}">source</a>
</nav>
</header>
<main>
<article>
{body_html}
{signatories_html}
</article>
</main>
<footer>
<a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a> · <a href="/sitemap.xml">sitemap</a> · <a href="/llms.txt">llms.txt</a> · <a href="https://github.com/{SITE['repo']}">source</a>
</footer>
</body>
</html>"""
def main():
readme_text = README.read_text()
# Strip frontmatter if present (for backwards compat)
if readme_text.startswith("---"):
end = readme_text.index("---", 3)
readme_text = readme_text[end + 3:].strip()
print("Fetching stargazers...", file=sys.stderr)
users = fetch_stargazers()
print(f" Found {len(users)} stargazers", file=sys.stderr)
stats = fetch_repo_stats()
print(f" {stats['forks']} forks, {stats['watchers']} watching", file=sys.stderr)
body_html = md_to_html(readme_text)
signatories_html = build_signatories_html(users, stats)
OUTPUT.mkdir(exist_ok=True)
build_og_image(len(users))
(OUTPUT / "index.html").write_text(build_page(body_html, signatories_html))
(OUTPUT / "sitemap.xml").write_text(
f'<?xml version="1.0" encoding="UTF-8"?>\n'
f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
f'<url><loc>{SITE["base_url"]}/</loc><priority>1.0</priority>'
f'<changefreq>weekly</changefreq></url>\n</urlset>'
)
(OUTPUT / "robots.txt").write_text(
f'User-agent: *\nAllow: /\n\n'
f'User-agent: GPTBot\nAllow: /\n\n'
f'User-agent: ClaudeBot\nAllow: /\n\n'
f'User-agent: PerplexityBot\nAllow: /\n\n'
f'Sitemap: {SITE["base_url"]}/sitemap.xml\n'
)
(OUTPUT / "llms.txt").write_text(
f'# {SITE["title"]}\n\n'
f'> {SITE["description"]}\n\n'
f'## Author\n- [{SITE["author"]}](https://greynewell.com)\n\n'
f'## Source\n- [GitHub](https://github.com/{SITE["repo"]})\n'
)
(OUTPUT / "CNAME").write_text("evaldriven.org\n")
print("Build complete!", file=sys.stderr)
for f in sorted(OUTPUT.iterdir()):
if f.is_file():
print(f" {f.name} ({f.stat().st_size} bytes)", file=sys.stderr)
if __name__ == "__main__":
main()