Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/crates/site-builder/src/main.rs # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / crates / site-builder / src / main.rs` 1210 lines ยท 59458 bytes Raw Blame History 1 mod collector; 2 mod components; 3 mod facts; 4 mod forge; 5 mod ledger_public; 6 mod oracle; 7 mod layouts; 8 mod seo; 9 10 use std::fs; 11 use std::io::Write; 12 use std::path::{Path, PathBuf}; 13 use std::time::Instant; 14 15 use layouts::base::{render_base_layout, render_page_layout}; 16 use maud::{html, DOCTYPE}; 17 18 fn copy_dir_all(src: &Path, dst: &Path) -> std::io::Result<()> { 19 if !src.exists() { 20 return Ok(()); 21 } 22 fs::create_dir_all(dst)?; 23 for entry in fs::read_dir(src)? { 24 let entry = entry?; 25 let ty = entry.file_type()?; 26 let from = entry.path(); 27 if entry.file_name() == ".crumb" || entry.file_name() == ".crumb.local" { continue; } 28 let to = dst.join(entry.file_name()); 29 if ty.is_dir() { 30 copy_dir_all(&from, &to)?; 31 } else { 32 fs::copy(&from, &to)?; 33 } 34 } 35 Ok(()) 36 } 37 38 fn render_aienet_document() -> maud::Markup { 39 render_page_layout( 40 "Sign your agent up for Aienet | AienOS", 41 "Human-authorized public agent signup for the Aienet prototype, using Agora profiles.", 42 "https://www.aienos.com/aienet/", 43 "website", 44 html! { 45 link rel="stylesheet" href="/assets/agora.css"; 46 @if components::agora::AIENET_HELLO_FORM { script src="/js/aienet.js" defer {} } 47 }, 48 components::agora::render_aienet_page(), 49 ) 50 } 51 52 fn build_pure_rust_site(dist: &Path, facts_path: &Path) { 53 if let Ok(ledger) = fs::read_to_string("public/data/now.tsv") { 54 ledger_public::check_public(&ledger).expect("refusing to build with an unprojected public ledger"); 55 } else if Path::new("public/data/now.tsv").exists() { 56 panic!("refusing unreadable public ledger"); 57 } 58 let facts = facts::Facts::load(facts_path) 59 .unwrap_or_else(|e| panic!("Cannot build without facts: {e}. Run `site-builder facts {}` first.", facts_path.display())); 60 println!(" [FACTS] Using facts gathered at {} from {}", facts.generated_at, facts_path.display()); 61 println!(" [BUILD] Compiling pure Rust Maud static site into: {}", dist.display()); 62 fs::create_dir_all(dist.join("assets")).expect("Failed to create assets dir"); 63 fs::create_dir_all(dist.join("js")).expect("Failed to create js dir"); 64 65 // Copy public assets 66 let public_dir = Path::new("public"); 67 if public_dir.exists() { 68 for entry in fs::read_dir(public_dir).expect("Failed to read public dir") { 69 let entry = entry.expect("Valid entry"); 70 let path = entry.path(); 71 let name = entry.file_name(); 72 if name == ".crumb" || name == ".crumb.local" { continue; } 73 let dest = dist.join(&name); 74 if path.is_dir() { 75 copy_dir_all(&path, &dest).expect("Failed to copy public subfolder"); 76 } else { 77 fs::copy(&path, &dest).expect("Failed to copy public file"); 78 } 79 } 80 println!(" [ASSETS] Synced public/ assets into {}", dist.display()); 81 } 82 83 // Canonical project state for machines: rendered from the same 84 // source as the homepage status section (components::status), so 85 // the page, the JSON, and llms.txt can never drift apart. 86 fs::write( 87 dist.join("status.json"), 88 components::status::status_json(), 89 ) 90 .expect("Failed to write status.json"); 91 // The machines and speeds data, published next to the page that renders it. 92 fs::write(dist.join("machines.json"), components::machines::RAW) 93 .expect("Failed to write machines.json"); 94 println!(" [STATE] Wrote status.json from the canonical layer states"); 95 96 // Render landing page in Maud 97 let page_content = html! { 98 (components::alpha::render_alpha_entry()) 99 (components::lab::render_lab_entry()) 100 (components::home_loop::render_home_loop()) 101 (components::story::render_story()) 102 (components::machines::render_machines_section()) 103 (components::machines::render_speeds_section()) 104 (components::evidence::render_evidence()) 105 (components::matrix::render_matrix()) 106 (components::research::render_research()) 107 (components::terminal::render_terminal()) 108 (components::status::render_status(&facts)) 109 (components::follow::render_follow()) 110 }; 111 112 let full_document = render_base_layout(page_content); 113 let output_file = dist.join("index.html"); 114 fs::write(&output_file, full_document.into_string()).expect("Failed to write index.html"); 115 println!(" [PAGE] Emitted / (index.html)"); 116 fs::copy(facts_path, dist.join("facts.json")).expect("Failed to copy facts.json"); 117 println!(" [FACTS] Published /facts.json"); 118 119 // /start/: the newcomer route through the project. It carries no status 120 // figures of its own; it links to the canonical implementation list, 121 // evidence record and release record, and names the cross-project 122 // boundaries. 123 let start_page = render_page_layout( 124 components::start::TITLE, 125 components::start::DESCRIPTION, 126 components::start::URL, 127 "website", 128 html! {}, 129 components::start::render_start_page(), 130 ); 131 fs::create_dir_all(dist.join("start")).expect("Failed to create start dir"); 132 fs::write(dist.join("start/index.html"), start_page.into_string()) 133 .expect("Failed to write start/index.html"); 134 println!(" [PAGE] Emitted /start/ (index.html)"); 135 136 // Public project measurements, collected before compilation in CI. 137 let progress = render_page_layout( 138 "Project progress | AienOS", 139 "Explore the retained Aien project history: codebase growth, revisions, test footprint and verification activity, read from public GitHub sources and published with reviewed releases.", 140 "https://www.aienos.com/progress/", "website", 141 html! { 142 link rel="stylesheet" href="/assets/progress.css"; 143 script defer src="/vendor/d3-7.9.0.min.js" {} 144 script defer src="/js/project-progress.js" {} 145 }, components::progress::render_progress_page(), 146 ); 147 fs::create_dir_all(dist.join("progress")).expect("Create progress directory"); 148 fs::write(dist.join("progress/index.html"), progress.into_string()).expect("Write progress page"); 149 150 // Blog index page 151 let blog_index = render_page_layout( 152 "Blog | AienOS", 153 "Research notes on building Aien V2: what shipped, what the evidence says, and what remains an open question.", 154 "https://www.aienos.com/blog/", 155 "website", 156 html! {}, 157 components::blog::render_blog_index(), 158 ); 159 let blog_index_dir = dist.join("blog"); 160 fs::create_dir_all(&blog_index_dir).expect("Failed to create blog dir"); 161 fs::write(blog_index_dir.join("index.html"), blog_index.into_string()) 162 .expect("Failed to write blog index.html"); 163 println!(" [PAGE] Emitted /blog (index.html)"); 164 165 // First post: the AIEN V3 research plan 166 let blog_post = render_page_layout( 167 &format!("{} | AienOS Blog", components::blog::POST_TITLE), 168 components::blog::POST_DESCRIPTION, 169 &format!("https://www.aienos.com/blog/{}/", components::blog::POST_SLUG), 170 "article", 171 html! {}, 172 components::blog::render_blog_post(), 173 ); 174 let post_dir = blog_index_dir.join(components::blog::POST_SLUG); 175 fs::create_dir_all(&post_dir).expect("Failed to create post dir"); 176 fs::write(post_dir.join("index.html"), blog_post.into_string()) 177 .expect("Failed to write post index.html"); 178 println!(" [PAGE] Emitted /blog/{} (index.html)", components::blog::POST_SLUG); 179 180 // Research status: ladder, experiment cards, and implementation list, 181 // all rendered from data/research_status.json. The data file itself is 182 // published next to it so machines read the same source. 183 let research_status = render_page_layout( 184 "Research status | AienOS", 185 "Where the Aien research stands: the qualification ladder, every experiment with its verdict, receipt and limits, and what is built versus still a hypothesis.", 186 "https://www.aienos.com/research/status/", 187 "website", 188 html! {}, 189 components::research_status::render_research_status_page(), 190 ); 191 let research_status_dir = dist.join("research/status"); 192 fs::create_dir_all(&research_status_dir).expect("Failed to create research/status dir"); 193 fs::write(research_status_dir.join("index.html"), research_status.into_string()) 194 .expect("Failed to write research/status/index.html"); 195 fs::write(dist.join("research-status.json"), components::research_status::RAW) 196 .expect("Failed to write research-status.json"); 197 println!(" [PAGE] Emitted /research/status (index.html) and /research-status.json"); 198 199 // /now/: the live coordination ledger, laid into public/data/now.tsv by 200 // the pages workflow from the data/now branch (components::now). 201 let now = components::now::load(); 202 let now_page = render_page_layout( 203 components::now::TITLE, 204 components::now::DESCRIPTION, 205 components::now::URL, 206 "website", 207 html! { link rel="stylesheet" href="/assets/now.css"; }, 208 components::now::render_now_page(&now), 209 ); 210 fs::create_dir_all(dist.join("now")).expect("Failed to create now dir"); 211 fs::write(dist.join("now/index.html"), now_page.into_string()).expect("Failed to write now/index.html"); 212 fs::write(dist.join("now.json"), components::now::to_json(&now)).expect("Failed to write now.json"); 213 println!(" [PAGE] Emitted /now/ ({} ledger lines) and /now.json", now.items.len()); 214 // /dash/: the one-screen dashboard, from accounts.tsv and routing.tsv on data/now. 215 let dash = components::dash::load(); 216 let dash_page = render_page_layout( 217 components::dash::TITLE, 218 components::dash::DESCRIPTION, 219 components::dash::URL, 220 "website", 221 html! { link rel="stylesheet" href="/assets/dash.css"; }, 222 components::dash::render_dash_page(&dash, &now), 223 ); 224 fs::create_dir_all(dist.join("dash")).expect("Failed to create dash dir"); 225 fs::write(dist.join("dash/index.html"), dash_page.into_string()).expect("Failed to write dash/index.html"); 226 println!(" [PAGE] Emitted /dash/ ({} quota accounts)", dash.quota.accounts.len()); 227 let hive_page = render_page_layout( 228 components::hive::TITLE, 229 components::hive::DESCRIPTION, 230 components::hive::URL, 231 "website", 232 html! { 233 link rel="stylesheet" href="/assets/hive.css"; 234 script defer src="/js/hive.js" {} 235 }, 236 components::hive::render_hive_page(), 237 ); 238 fs::create_dir_all(dist.join("hive")).expect("Create Hive directory"); 239 fs::write(dist.join("hive/index.html"), hive_page.into_string()).expect("Write Hive page"); 240 let allen_page = render_page_layout( 241 components::allen::TITLE, 242 components::allen::DESCRIPTION, 243 components::allen::URL, 244 "website", 245 html! { 246 link rel="stylesheet" href="/assets/allen.css"; 247 link rel="stylesheet" href="/assets/allen-panes.css"; 248 script defer src="/js/allen.js" {} 249 script defer src="/js/allen-scene.js" {} 250 script defer src="/js/allen-audio.js" {} 251 script defer src="/js/allen-panes.js" {} 252 script defer src="/js/aien-universe.js" {} 253 }, 254 components::allen::render_allen_page(), 255 ); 256 fs::create_dir_all(dist.join("aien")).expect("Create Aien directory"); 257 fs::write(dist.join("aien/index.html"), allen_page.into_string()).expect("Write Aien page"); 258 // Programs Aien writes run in this document, never in a srcdoc frame, which 259 // would inherit the page policy (components::csp). A direct visitor sees 260 // the shared header and footer and a pointer back to /aien/. 261 let run_page = html! { 262 (DOCTYPE) 263 html lang="en" { 264 head { 265 meta charset="utf-8"; 266 meta name="viewport" content="width=device-width, initial-scale=1"; 267 title { "Program runner | AienOS" } 268 meta name="description" content="Runs a program Aien wrote, sandboxed, inside the Aien page."; 269 meta name="robots" content="noindex"; 270 link rel="icon" type="image/svg+xml" href="/favicon.svg"; 271 link rel="stylesheet" href="/assets/style.css"; 272 link rel="stylesheet" href="/assets/site-nav.css"; 273 link rel="stylesheet" href="/assets/turing-look.css"; 274 script src=(components::csp::RUNNER_SCRIPT) {} 275 } 276 body { 277 div id="root" style="min-height: 100vh; display: flex; flex-direction: column;" { 278 (components::navbar::render_navbar()) 279 main id="main-content" style="flex: 1;" { 280 section class="container" { 281 p { "This document runs programs Aien writes, inside a sandboxed frame on " a href="/aien/" { "aienos.com/aien/" } "." } 282 } 283 } 284 (components::footer::render_footer()) 285 } 286 } 287 } 288 }; 289 fs::write(dist.join(components::csp::RUNNER_PATH), components::csp::enrich(run_page.into_string())).expect("Write the program runner"); 290 // Old addresses (seo::REDIRECTS) forward visitors, with any ?query and #hash, 291 // to the new one; /js/redirect.js reads the target from data-to. 292 for (old, new) in seo::REDIRECTS { 293 let page = render_page_layout( 294 &format!("Moved to {new} | AienOS"), 295 &format!("This page moved to {new}."), 296 &format!("https://www.aienos.com{new}"), 297 "website", 298 html! { 299 meta name="robots" content="noindex"; 300 meta http-equiv="refresh" content=(format!("0; url={new}")); 301 script src="/js/redirect.js" data-to=(new) {} 302 }, 303 html! { 304 section class="container" { 305 p { "This page moved to " a href=(new) { "aienos.com" (new) } "." } 306 } 307 }, 308 ); 309 let dir = dist.join(old.trim_matches('/')); 310 fs::create_dir_all(&dir).expect("Create redirect directory"); 311 fs::write(dir.join("index.html"), components::csp::enrich(page.into_string())).expect("Write redirect page"); 312 } 313 let alpha_page = render_page_layout( 314 components::alpha::TITLE, 315 components::alpha::DESCRIPTION, 316 components::alpha::URL, 317 "website", 318 html! { 319 link rel="stylesheet" href="/assets/alpha.css"; 320 script defer src="/js/alpha.js" {} 321 }, 322 components::alpha::render_alpha_page(), 323 ); 324 fs::create_dir_all(dist.join("alpha")).expect("Create Alpha directory"); 325 fs::write(dist.join("alpha/index.html"), alpha_page.into_string()).expect("Write Alpha page"); 326 let lab_page = render_page_layout( 327 components::lab::TITLE, 328 components::lab::DESCRIPTION, 329 components::lab::URL, 330 "website", 331 html! { 332 link rel="stylesheet" href="/assets/lab.css"; 333 script defer src="/js/lab.js" {} 334 }, 335 components::lab::render_lab_page(), 336 ); 337 fs::create_dir_all(dist.join("lab")).expect("Create Lab directory"); 338 fs::write(dist.join("lab/index.html"), lab_page.into_string()).expect("Write Lab page"); 339 let learn_page = render_page_layout( 340 components::learn::TITLE, 341 components::learn::DESCRIPTION, 342 components::learn::URL, 343 "website", 344 html! { link rel="stylesheet" href="/assets/learn.css"; }, 345 components::learn::render_learn_page(), 346 ); 347 fs::create_dir_all(dist.join("learn")).expect("Create learning directory"); 348 fs::write(dist.join("learn/index.html"), learn_page.into_string()).expect("Write learning page"); 349 // /engineer/: About the engineer, drakestapleton.com merged into this site. 350 components::engineer::emit(dist, &facts); 351 // /agents/: every public repository with its agent instructions, from 352 // public/data/agent-repos.json (refreshed by `site-builder agents`). 353 let agent_repos = components::agents::Repos::load(Path::new(components::agents::DATA_PATH)) 354 .unwrap_or_else(|e| panic!("agents: {e}")); 355 let agents_page = render_page_layout( 356 components::agents::TITLE, 357 components::agents::DESCRIPTION, 358 components::agents::URL, 359 "website", 360 html! {}, 361 components::agents::render_agents_page(&agent_repos), 362 ); 363 fs::create_dir_all(dist.join("agents")).expect("Failed to create agents dir"); 364 fs::write(dist.join("agents/index.html"), agents_page.into_string()).expect("Failed to write agents/index.html"); 365 println!(" [PAGE] Emitted /agents/ ({} repositories)", agent_repos.listed().len()); 366 let agents_hello_page = render_page_layout( 367 components::agents_hello::TITLE, 368 components::agents_hello::DESCRIPTION, 369 components::agents_hello::URL, 370 "website", 371 html! {}, 372 components::agents_hello::render_agents_hello_page(), 373 ); 374 fs::create_dir_all(dist.join("agents/hello")).expect("Failed to create agents/hello dir"); 375 fs::write(dist.join("agents/hello/index.html"), agents_hello_page.into_string()).expect("Failed to write agents/hello/index.html"); 376 println!(" [PAGE] Emitted /agents/hello/"); 377 378 let agents_knowledge_page = render_page_layout( 379 components::agents_knowledge::TITLE, 380 components::agents_knowledge::DESCRIPTION, 381 components::agents_knowledge::URL, 382 "website", 383 html! {}, 384 components::agents_knowledge::render_agents_knowledge_page(), 385 ); 386 fs::create_dir_all(dist.join("agents/knowledge")).expect("Failed to create agents/knowledge dir"); 387 fs::write(dist.join("agents/knowledge/index.html"), agents_knowledge_page.into_string()).expect("Failed to write agents/knowledge/index.html"); 388 println!(" [PAGE] Emitted /agents/knowledge/"); 389 390 let agora_page = render_page_layout( 391 components::agora::TITLE, 392 components::agora::DESCRIPTION, 393 components::agora::URL, 394 "website", 395 html! { 396 link rel="stylesheet" href="/assets/agora.css"; 397 script defer src="/js/agora.js" {} 398 }, 399 components::agora::render_agora_page(), 400 ); 401 fs::create_dir_all(dist.join("agora")).expect("Failed to create agora dir"); 402 fs::write(dist.join("agora/index.html"), agora_page.into_string()).expect("Failed to write agora/index.html"); 403 println!(" [PAGE] Emitted /agora/"); 404 405 let aienet_page = render_aienet_document(); 406 fs::create_dir_all(dist.join("aienet")).expect("Failed to create aienet dir"); 407 fs::write(dist.join("aienet/index.html"), aienet_page.into_string()).expect("Failed to write aienet/index.html"); 408 println!(" [PAGE] Emitted /aienet/"); 409 410 let agora_meet_page = render_page_layout( 411 components::agora_meet::TITLE, 412 components::agora_meet::DESCRIPTION, 413 components::agora_meet::URL, 414 "website", 415 html! {}, 416 components::agora_meet::render_agora_meet_page(), 417 ); 418 fs::create_dir_all(dist.join("agora/meet")).expect("Failed to create agora/meet dir"); 419 fs::write(dist.join("agora/meet/index.html"), agora_meet_page.into_string()).expect("Failed to write agora/meet/index.html"); 420 println!(" [PAGE] Emitted /agora/meet/"); 421 422 let agora_protocol_page = render_page_layout( 423 components::agora_protocol::TITLE, 424 components::agora_protocol::DESCRIPTION, 425 components::agora_protocol::URL, 426 "website", 427 html! {}, 428 components::agora_protocol::render_agora_protocol_page(), 429 ); 430 fs::create_dir_all(dist.join("agora/protocol")).expect("Failed to create agora/protocol dir"); 431 fs::write(dist.join("agora/protocol/index.html"), agora_protocol_page.into_string()).expect("Failed to write agora/protocol/index.html"); 432 println!(" [PAGE] Emitted /agora/protocol/"); 433 434 let agora_network_page = render_page_layout( 435 components::agora_network::TITLE, 436 components::agora_network::DESCRIPTION, 437 components::agora_network::URL, 438 "website", 439 html! {}, 440 components::agora_network::render_agora_network_page(), 441 ); 442 fs::create_dir_all(dist.join("agora/network")).expect("Failed to create agora/network dir"); 443 fs::write(dist.join("agora/network/index.html"), agora_network_page.into_string()).expect("Failed to write agora/network/index.html"); 444 println!(" [PAGE] Emitted /agora/network/"); 445 // /omega/: what Omega is, from data/omega.json (the omega repository's 446 // docs/OMEGA.md), published next to it as /omega.json. 447 let omega_page = render_page_layout( 448 components::omega::TITLE, 449 components::omega::DESCRIPTION, 450 components::omega::URL, 451 "website", 452 html! { link rel="stylesheet" href="/assets/omega.css"; }, 453 components::omega::render_omega_page(), 454 ); 455 fs::create_dir_all(dist.join("omega")).expect("Failed to create omega dir"); 456 fs::write(dist.join("omega/index.html"), omega_page.into_string()).expect("Failed to write omega/index.html"); 457 fs::write(dist.join("omega.json"), components::omega::RAW).expect("Failed to write omega.json"); 458 println!(" [PAGE] Emitted /omega/ and /omega.json"); 459 // /omega/reference/: the agent-facing language reference, written by 460 // seeded Omega (om/omega-reference/page.om, gated by its check.sh). 461 let omega_ref_page = render_page_layout( 462 components::omega_reference::TITLE, 463 components::omega_reference::DESCRIPTION, 464 components::omega_reference::URL, 465 "website", 466 html! { link rel="stylesheet" href="/assets/omega.css"; }, 467 components::omega_reference::render_omega_reference_page(), 468 ); 469 fs::create_dir_all(dist.join("omega/reference")).expect("Failed to create omega/reference dir"); 470 fs::write(dist.join("omega/reference/index.html"), omega_ref_page.into_string()).expect("Failed to write omega/reference/index.html"); 471 println!(" [PAGE] Emitted /omega/reference/"); 472 473 // /cudaplusplus/: CUDA++, the GPU half of Omega, from 474 // data/cudaplusplus.json, published next to it as /cudaplusplus.json. 475 let cudapp_page = render_page_layout( 476 components::cudaplusplus::TITLE, 477 components::cudaplusplus::DESCRIPTION, 478 components::cudaplusplus::URL, 479 "website", 480 html! { link rel="stylesheet" href="/assets/omega.css"; link rel="stylesheet" href="/assets/cudaplusplus.css"; }, 481 components::cudaplusplus::render_cudaplusplus_page(), 482 ); 483 fs::create_dir_all(dist.join("cudaplusplus")).expect("Failed to create cudaplusplus dir"); 484 fs::write(dist.join("cudaplusplus/index.html"), cudapp_page.into_string()).expect("Failed to write cudaplusplus/index.html"); 485 fs::write(dist.join("cudaplusplus.json"), components::cudaplusplus::RAW).expect("Failed to write cudaplusplus.json"); 486 println!(" [PAGE] Emitted /cudaplusplus/ and /cudaplusplus.json"); 487 488 // Research narrative pages (NARR-RESEARCH): The Machine and Scientific Discovery 489 for (slug, title, description, url, body) in [ 490 ( 491 "machine", 492 components::machine::TITLE, 493 components::machine::DESCRIPTION, 494 components::machine::URL, 495 components::machine::render_machine(), 496 ), 497 ( 498 "discovery", 499 components::discovery::TITLE, 500 components::discovery::DESCRIPTION, 501 components::discovery::URL, 502 components::discovery::render_discovery(), 503 ), 504 ( 505 "owned", 506 components::owned::TITLE, 507 components::owned::DESCRIPTION, 508 components::owned::URL, 509 components::owned::render_owned(), 510 ), 511 ] { 512 let page = render_page_layout(title, description, url, "article", html! {}, body); 513 let page_dir = dist.join(slug); 514 fs::create_dir_all(&page_dir).expect("Failed to create narrative page dir"); 515 fs::write(page_dir.join("index.html"), page.into_string()) 516 .expect("Failed to write narrative page index.html"); 517 println!(" [PAGE] Emitted /{}/ (index.html)", slug); 518 } 519 520 // Glossary: the terms of the project, each linked to where it is used. 521 let glossary = render_page_layout( 522 components::glossary::TITLE, 523 components::glossary::DESCRIPTION, 524 components::glossary::URL, 525 "website", 526 html! {}, 527 components::glossary::render_glossary(), 528 ); 529 fs::create_dir_all(dist.join("glossary")).expect("Failed to create glossary dir"); 530 fs::write(dist.join("glossary/index.html"), glossary.into_string()) 531 .expect("Failed to write glossary/index.html"); 532 println!(" [PAGE] Emitted /glossary/ (index.html)"); 533 534 let privacy = render_page_layout( 535 "Privacy & saying hello to Aien | AienOS", 536 "Privacy, operational logs and the separate choices for talking to Aien. No advertising trackers.", 537 "https://www.aienos.com/privacy/", 538 "website", 539 html! {}, 540 components::allen_intro::render_privacy(), 541 ); 542 fs::create_dir_all(dist.join("privacy")).expect("Create privacy directory"); 543 fs::write(dist.join("privacy/index.html"), privacy.into_string()).expect("Write privacy page"); 544 545 // Where I am and how to reach me: X, email, Allen and the forge. 546 let contact = render_page_layout( 547 components::contact::TITLE, 548 components::contact::DESCRIPTION, 549 components::contact::URL, 550 "website", 551 html! {}, 552 components::contact::render_contact(), 553 ); 554 fs::create_dir_all(dist.join("contact")).expect("Create contact directory"); 555 fs::write(dist.join("contact/index.html"), contact.into_string()).expect("Write contact page"); 556 557 let support = render_page_layout( 558 components::support::TITLE, 559 components::support::DESCRIPTION, 560 components::support::URL, 561 "website", 562 html! {}, 563 components::support::render_page(), 564 ); 565 fs::create_dir_all(dist.join("support")).expect("Create support directory"); 566 fs::write(dist.join("support/index.html"), support.into_string()).expect("Write support page"); 567 568 let still_building = render_page_layout( 569 components::still_building::TITLE, 570 components::still_building::DESCRIPTION, 571 components::still_building::URL, 572 "website", 573 html! { link rel="stylesheet" href="/assets/still-building.css"; }, 574 components::still_building::render_page(), 575 ); 576 fs::create_dir_all(dist.join("still-building")).expect("Create still-building directory"); 577 fs::write(dist.join("still-building/index.html"), still_building.into_string()).expect("Write still-building page"); 578 println!(" [PAGE] Emitted /contact/ (index.html)"); 579 580 // Section hubs: /experiments/, /evidence/, /philosophy/ (NARR-NAV) 581 components::hubs::emit_hub_pages(dist); 582 583 // The 404 page, served by SiteHub on my own hardware for any address that has no file. 584 let not_found = render_page_layout( 585 "Page not found | AienOS", 586 "There is nothing at this address. Every page of AienOS is listed in llms.txt and the sitemap; the front page, the machine and the research are one link away.", 587 "", 588 "website", 589 seo::head_404(), 590 seo::render_404(), 591 ); 592 fs::write(dist.join("404.html"), components::csp::enrich(components::allen_intro::enrich(components::support::enrich(not_found.into_string())))).expect("Failed to write 404.html"); 593 594 // Every page written above (generated or copied from public/) gets the same 595 // head: www canonical, cards, feeds, JSON-LD. Then the machine 596 // surface is written from the pages that actually exist. 597 let ctx = seo::BuildCtx::gather(&now, &facts.generated_at); 598 let pages = seo::enrich(dist, &ctx); 599 seo::write_machine_surface(dist, &pages, &now, &ctx, &components::status::llms_txt()); 600 } 601 602 fn comparison_page_key(dist: &Path, path: &Path) -> String { 603 let rel = path.strip_prefix(dist).unwrap_or(path); 604 let rel = rel.to_string_lossy().replace('\\', "/"); 605 let source = format!("public/{rel}"); 606 if components::machines::is_prose_exempt(&source) { 607 source 608 } else { 609 rel 610 } 611 } 612 613 fn is_scanned_comparison_file(path: &Path) -> bool { 614 let name = path.file_name().and_then(|n| n.to_str()).unwrap_or(""); 615 path.extension().and_then(|e| e.to_str()) == Some("html") 616 || name == "llms.txt" 617 || name == "llms-full.txt" 618 } 619 620 fn collect_comparison_pages(dist: &Path, dir: &Path, bad: &mut Vec<(PathBuf, String)>) -> Result<(), String> { 621 let rd = match fs::read_dir(dir) { 622 Ok(rd) => rd, 623 Err(e) => { 624 let msg = format!("unreadable directory {}: {e}", dir.display()); 625 eprintln!("{msg}"); 626 return Err(msg); 627 } 628 }; 629 for entry in rd { 630 let entry = match entry { 631 Ok(entry) => entry, 632 Err(e) => { 633 let msg = format!("unreadable directory entry in {}: {e}", dir.display()); 634 eprintln!("{msg}"); 635 return Err(msg); 636 } 637 }; 638 let path = entry.path(); 639 if path.is_dir() { 640 collect_comparison_pages(dist, &path, bad)?; 641 } else if is_scanned_comparison_file(&path) { 642 let content = match fs::read_to_string(&path) { 643 Ok(content) => content, 644 Err(e) => { 645 let msg = format!("unreadable file {}: {e}", path.display()); 646 eprintln!("{msg}"); 647 return Err(msg); 648 } 649 }; 650 if path.file_name().and_then(|n| n.to_str()) == Some("llms-full.txt") { 651 let ledger = fs::read_to_string(dist.join("data/now.tsv")).unwrap_or_default(); 652 for problem in components::machines::llms_full_problems(&content, &ledger) { 653 bad.push((path.clone(), problem)); 654 } 655 } else { 656 let key = comparison_page_key(dist, &path); 657 for problem in components::machines::comparison_errors_at(&key, &content) { 658 bad.push((path.clone(), problem)); 659 } 660 } 661 } 662 } 663 Ok(()) 664 } 665 666 fn verify_site(dist: &Path) { 667 let index_file = dist.join("index.html"); 668 let ledger_path = dist.join("data/now.tsv"); 669 if ledger_path.exists() { 670 let ledger = fs::read_to_string(&ledger_path).expect("unreadable published ledger"); 671 ledger_public::check_public(&ledger).expect("refusing unprojected published ledger"); 672 } 673 assert!(index_file.exists(), "Required index.html missing in {}", dist.display()); 674 // No translated copy, the registry both ways, every head, the six 675 // destinations on every page, the root's Allen door and classic links 676 // (oracle::check_root), every script and stylesheet resolving inside 677 // dist, and every published data file: gates that hold on any tree. 678 oracle::verify(dist); 679 680 // The root is Allen's native front door (the approved redesign); the 681 // former front page lives whole at /classic/ and is checked below. 682 let root = fs::read_to_string(&index_file).expect("Failed to read index.html"); 683 assert!(!root.contains("fonts.googleapis.com"), "Outside font loaded in index.html"); 684 assert!(!root.contains('\u{2014}') && !root.contains('\u{2013}'), "Forbidden dash in index.html"); 685 686 let classic_file = dist.join("classic/index.html"); 687 let content = fs::read_to_string(&classic_file).expect("Failed to read classic/index.html, the former front page"); 688 689 // The former front page, now /classic/: every invariant it carried. 690 assert!(content.contains("