From 0ae3dfc18b749de38ed98dd2b7370df93b061279 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 23 Oct 2026 19:33:24 -0500 Subject: [PATCH] Make the site readable by agents: sitemap.md, AGENTS.md, markdown mirrors The scan at agent-ready.dev scored aienos.com 65/100 and failed every agent-discovery surface except llms.txt. This adds them from the existing page registry, so the HTML, the XML sitemap, llms.txt and the new files cannot drift apart. - Generate /sitemap.md with H2 sections and described links. - Publish AGENTS.md at /AGENTS.md, with Installation, Configuration and Usage and executable commands. - Write a Markdown mirror for every page at the same path with .md (/index.md, /machine.md, /zh-CN/...), with YAML frontmatter and a Sitemap section. The body is converted from the final HTML. - Add rel=alternate type=text/markdown, rel=describedby to llms.txt, and robots snippet directives to every head. - Put BreadcrumbList on the homepage JSON-LD as well as every subpage. - Add /glossary/ and link it from the footer. - Link every llms.txt current-state line and the research line; the scan found nine unlinked items in H2 sections. - Label the terminal input so its accessible name contains the visible placeholder text. - Verify the discovery files, mirrors, head signals and glossary in the build, and pin the mirror path and link-format rules in tests. --- AGENTS.md | 79 +++++++++ README.md | 13 ++ crates/site-builder/src/components/footer.rs | 7 +- .../site-builder/src/components/glossary.rs | 107 +++++++++++++ crates/site-builder/src/components/mod.rs | 1 + crates/site-builder/src/components/status.rs | 8 +- .../site-builder/src/components/terminal.rs | 2 +- crates/site-builder/src/main.rs | 14 ++ crates/site-builder/src/seo.rs | 150 ++++++++++++++++-- 9 files changed, 368 insertions(+), 13 deletions(-) create mode 100644 AGENTS.md create mode 100644 crates/site-builder/src/components/glossary.rs diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..2f8607c3 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,79 @@ +# AIENOS website (aienos.com) + +> Static site for aienos.com. One Rust program, `crates/site-builder`, renders every page from Maud templates, copies hand-written files from `public/`, then rewrites every head and writes the machine surface. GitHub Pages serves the output; `.github/workflows/pages.yml` builds and deploys it on every push to `main`. + +## Scope + +- Applies to the whole repository. +- Source of truth is `crates/site-builder/src` plus `public/`. The root `index.html` and `dist/` are not the live site. +- `dist/` is generated output. Never edit it by hand; rebuild it. + +## Installation + +```bash +git clone https://github.com/aien-dev/aienos.com.git +cd aienos.com +rustup toolchain install stable +cargo build --release --manifest-path crates/site-builder/Cargo.toml +``` + +There is no Node build, no `package.json`, and no package manager. The only tool needed is a Rust toolchain; the site depends on `maud`, `serde` and `serde_json`. + +## Configuration + +- `facts.json` at the repository root is read by every build. Refresh it from the public GitHub record when the fact sheet must move: + +```bash +GH_TOKEN="$(gh auth token)" cargo run --release --manifest-path crates/site-builder/Cargo.toml -- facts facts.json +``` + +- `public/data/project-progress.json` feeds `/progress/`. Recollect it with: + +```bash +GH_TOKEN="$(gh auth token)" cargo run --release --manifest-path crates/site-builder/Cargo.toml -- progress public/data/project-progress.json +``` + +- `CNAME` holds the custom domain. `.github/workflows/pages.yml` is the deployment configuration. +- `crates/site-builder/data/research_status.json` is the canonical research ladder and experiment verdicts. +- The page registry in `crates/site-builder/src/seo.rs` (`seo::PAGES`) drives the sitemap, `llms.txt`, `sitemap.md`, the feeds and the JSON-LD. Add every new page there or the build fails. + +## Usage + +```bash +# Full test suite +cargo test --manifest-path crates/site-builder/Cargo.toml + +# Build the site into dist/ (this also runs the integrity verifier) +cargo run --release --manifest-path crates/site-builder/Cargo.toml -- build dist + +# Re-check an existing dist/ without rebuilding +cargo run --release --manifest-path crates/site-builder/Cargo.toml -- verify dist + +# Preview the generated output locally +python3 -m http.server 8080 --directory dist +``` + +Open `http://127.0.0.1:8080/` after the preview server starts. GitHub Pages serves directories through `index.html`, so local previews match the live routes. + +## Conventions + +- Generated pages are Maud markup in `crates/site-builder/src/components/`. Hand-written pages live under `public//index.html` and are copied verbatim. +- Every page gets its head rewritten by `seo::enrich`: canonical on `https://www.aienos.com`, Open Graph and Twitter cards, hreflang, JSON-LD, `rel="alternate" type="text/markdown"`, `rel="describedby"` to `/llms.txt`, and robots snippet directives. Do not duplicate those tags in a component. +- Every page also gets a Markdown mirror at the same path with `.md` (`/` becomes `/index.md`), with YAML frontmatter and a `## Sitemap` section. The mirror is generated from the final HTML; do not hand-write one. +- Copy rules: no em dashes, no en dashes, no outside fonts, scripts or trackers. The verifier fails the build on a dash in a page. +- Keep one source for machine-readable state. `status.json`, the status section, and the current-state lines in `llms.txt` all read `components::status::layer_states()`. +- Tests live beside the code in `#[cfg(test)]` modules. Add a test when a rule can regress silently. + +## Safety and approvals + +- Ask before changing the canonical host, the page registry shape, or a published claim that carries a receipt. +- Never commit tokens, API keys, or `.env` files. `GH_TOKEN` is read from the environment and is never written into the site. +- Never publish `dist/`, `.crumb.local`, or private evidence. `.gitignore` and the copy step already exclude local coordination files. +- Do not run destructive git commands or rewrite published history. Work on a branch, run the full test suite and `build dist`, then merge through a pull request. + +## Further reading + +- `README.md`: the human-facing build and deployment guide. +- `crates/site-builder/src/seo.rs`: the page registry, head pass, sitemap, llms files and machine surface. +- `https://www.aienos.com/llms.txt`: the site as AI readers see it. +- `https://www.aienos.com/sitemap.md`: every page, grouped and described. diff --git a/README.md b/README.md index f01154b7..7383ce2e 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,19 @@ cargo run --release --manifest-path crates/site-builder/Cargo.toml -- verify dis `build dist` writes the site to `dist/` and then verifies it; `verify dist` re-checks an existing output directory. There is no dev server or preview command. `.github/workflows/pages.yml` runs the same steps (plus the progress collection described below) and deploys `dist/` to GitHub Pages on pushes to `main`. +## Agent surface + +The build also writes the files AI agents probe, all from the same page registry in `crates/site-builder/src/seo.rs`: + +- `/llms.txt` and `/llms-full.txt`: the site index and the full text. +- `/sitemap.md`: the readable twin of `sitemap.xml`, H2 sections of described links. +- `/AGENTS.md`: the repository brief for coding agents (`AGENTS.md` at the repository root is published unchanged). It carries Installation, Configuration and Usage with executable commands. +- A Markdown mirror for every page at the same path with `.md`, so `/` is `/index.md` and `/machine/` is `/machine.md`. Each mirror carries YAML frontmatter (`title`, `description`, `last_updated`, `canonical_url`), the page body converted from the final HTML, and a `## Sitemap` section. +- Head signals on every page: ``, `` to `/llms.txt`, and robots directives for `max-snippet:-1` and `max-image-preview:large`. +- `/glossary/`: the terms the project uses in its own sense, linked from the footer of every page. + +GitHub Pages serves static files only. It cannot vary a response on `Accept: text/markdown` and cannot add a `Link` header to a Markdown response, so those two agent-readability checks (content negotiation and the Markdown `Link` header) need an edge proxy or a request-aware host. Every other discovery file and page signal is generated at build time. + ## License Licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later). See [LICENSE](LICENSE). The runtime itself, aien-sovereign-core, is also AGPL-3.0-or-later. Project values live in the nonbinding [COVENANT.md](https://github.com/aien-dev/aien-sovereign-core/blob/main/COVENANT.md), which grants and restricts no legal rights. diff --git a/crates/site-builder/src/components/footer.rs b/crates/site-builder/src/components/footer.rs index 76ddfc4a..957605e0 100644 --- a/crates/site-builder/src/components/footer.rs +++ b/crates/site-builder/src/components/footer.rs @@ -59,10 +59,11 @@ pub const FOOTER_GROUPS: [(&str, &[FooterLink]); 6] = [ ]; /// Secondary links, after the six sections. -const FOOTER_MORE: [FooterLink; 6] = [ +const FOOTER_MORE: [FooterLink; 7] = [ ("Progress", "/progress/", false), ("Blog", "/blog", false), ("Follow", "/#follow", false), + ("Glossary", "/glossary/", false), ("Licensing", "/licensing/", false), ("GitHub", "https://github.com/aien-dev", true), ("Drake Stapleton", "https://www.drakestapleton.com", true), @@ -102,6 +103,10 @@ pub fn render_footer() -> Markup { " · " a href="/llms-full.txt" { "full text" } " · " + a href="/sitemap.md" { "sitemap.md" } + " · " + a href="/AGENTS.md" { "AGENTS.md" } + " · " a href="/feed.xml" { "feed" } " · " a href="/now/feed.xml" { "ledger feed" } diff --git a/crates/site-builder/src/components/glossary.rs b/crates/site-builder/src/components/glossary.rs new file mode 100644 index 00000000..984a4fb8 --- /dev/null +++ b/crates/site-builder/src/components/glossary.rs @@ -0,0 +1,107 @@ +use maud::{html, Markup}; + +pub const TITLE: &str = "Glossary | AIENOS"; +pub const DESCRIPTION: &str = "The terms AIENOS uses in its own sense: the Turing, receipts, crumbs, the loop, the agents that surround it, and the five machines."; +pub const URL: &str = "https://www.aienos.com/glossary/"; + +fn term(name: &str, definition: Markup) -> Markup { + html! { + dt style="font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--accent-green); margin-top: 20px;" { (name) } + dd style="color: var(--text-secondary); font-size: 16px; line-height: 1.7; margin: 4px 0 0 0;" { (definition) } + } +} + +pub fn render_glossary() -> Markup { + html! { + section id="glossary" style="padding: 80px 0; border-bottom: 1px solid var(--border-subtle);" { + div class="container" style="max-width: 820px;" { + div class="badge badge-blue" style="margin-bottom: 12px;" { "TERMINOLOGY" } + h1 style="font-size: clamp(32px, 5vw, 48px); font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); margin: 0 0 16px 0;" { + "Glossary" + } + p style="color: var(--text-secondary); font-size: 17px; line-height: 1.7; margin-bottom: 12px;" { + "The terms this site uses in its own sense. Each definition points at the page where the term does real work, so a reader can check the usage rather than trust the summary." + } + p style="color: var(--text-muted); font-size: 14px; line-height: 1.6;" { + "Status: experimental, pre-alpha. Definitions change when the evidence changes." + } + + h2 style="font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 44px 0 4px 0;" { "The system" } + dl style="margin: 0;" { + (term("AIENOS", html! { + "The experimental, open source machine this site documents. A sovereign substrate that owns the hardware and keeps a persistent intelligence alive and continuous. Pre-alpha. See " + a href="/machine/" { "The Machine" } "." + })) + (term("AIEN", html! { + "The persistent intelligence that learns. Weights suggest, programs explain, verification decides, evidence teaches. See " + a href="/machine/" { "The Machine" } " and " a href="/research/" { "Research" } "." + })) + (term("Atlas", html! { + "The awakening layer, planned. The seed that wakes AIENOS on new hardware. Doctrine is published; implementation is ahead." + })) + (term("Omega", html! { + "The language for all computing, GPU to CPU. It turns intent into explicit programs that can be verified before they are trusted. See " + a href="/omega/" { "What Omega is" } "." + })) + (term("CUDA++", html! { + "The GPU half of Omega, MIT licensed, for the NVIDIA GPUs people already own. See " + a href="/cudaplusplus/" { "CUDA++" } "." + })) + (term("Turing", html! { + "The unit of net held-out explanatory compression. The site uses it to measure what a change actually explained. See " + a href="/turing/" { "the Turing field guide" } " and " + a href="/research/computing-machinery-and-understanding/" { "the preprint" } "." + })) + (term("Held-out", html! { + "Data not used while fitting, so a result on it measures transfer rather than recall." + })) + (term("The loop", html! { + "Propose, verify, measure, learn. The closed epistemic loop described on the front page." + })) + } + + h2 style="font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 44px 0 4px 0;" { "Around the loop" } + dl style="margin: 0;" { + (term("Cortex", html! { "The canonical memory. It keeps what the machine has established." })) + (term("Aegis", html! { "The verifier. It checks generated code and changes nothing." })) + (term("Forge", html! { "Realizes what Omega verified." })) + (term("Argus", html! { "Watches capability enforcement, so authority stays where it was granted." })) + } + + h2 style="font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 44px 0 4px 0;" { "Evidence and coordination" } + dl style="margin: 0;" { + (term("Receipt", html! { + "A public link to the evidence behind a claim: a pull request, a commit, a measured data file, or a record. See " + a href="/evidence/" { "Evidence" } "." + })) + (term("Crumb", html! { + "A durable coordination note under RFC-0001. Sniff before edits, respect unexpired locks, claim multi-step work, close with the result. No receipt, no crumb." + })) + (term("Research status", html! { + "The qualification ladder and every experiment with its verdict, receipt and limits. See " + a href="/research/status/" { "Research status" } "." + })) + (term("Post-LLM", html! { + "The position that a learning machine can keep knowledge as inspectable programs, with verification deciding what is trusted. See " + a href="/post-llm-case/" { "The Post-LLM Case" } "." + })) + } + + h2 style="font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 44px 0 4px 0;" { "The machines" } + dl style="margin: 0;" { + (term("DGX Spark", html! { "NVIDIA Grace Blackwell GB10 with 128 GB of unified memory. The development machine and the judge." })) + (term("iMac 2017", html! { "The x86_64 port of the native C kernel, running on bare metal." })) + (term("Raspberry Pi 5", html! { "The small machine." })) + (term("QEMU", html! { "The laboratory where every kernel boots first." })) + (term("The rig", html! { "The owned inference box." })) + } + + p style="color: var(--text-secondary); font-size: 16px; line-height: 1.7; margin-top: 40px;" { + "The same list is available to machines in " + a href="/llms.txt" { "llms.txt" } " and " + a href="/sitemap.md" { "sitemap.md" } "." + } + } + } + } +} diff --git a/crates/site-builder/src/components/mod.rs b/crates/site-builder/src/components/mod.rs index ded015c0..8bb65800 100644 --- a/crates/site-builder/src/components/mod.rs +++ b/crates/site-builder/src/components/mod.rs @@ -3,6 +3,7 @@ pub mod boxlink; pub mod discovery; pub mod evidence; pub mod footer; +pub mod glossary; pub mod home_loop; pub mod hubs; pub mod machine; diff --git a/crates/site-builder/src/components/status.rs b/crates/site-builder/src/components/status.rs index 16eb2268..20261b75 100644 --- a/crates/site-builder/src/components/status.rs +++ b/crates/site-builder/src/components/status.rs @@ -203,7 +203,13 @@ pub fn status_json() -> String { /// /llms.txt: the project in plain text for AI readers and crawlers, in /// the llms.txt convention (see `seo::llms_txt`), with the layer states. pub fn llms_txt() -> String { - let lines: Vec = layer_states().iter().map(|l| format!("{}: {}. {}", l.name, l.status, l.note)).collect(); + let lines: Vec = layer_states() + .iter() + .map(|l| { + let target = l.receipt_url.unwrap_or("https://www.aienos.com/status.json"); + format!("[{}]({}): {}. {}", l.name, target, l.status, l.note) + }) + .collect(); crate::seo::llms_txt(&lines, &rs::current_level_sentence()) } diff --git a/crates/site-builder/src/components/terminal.rs b/crates/site-builder/src/components/terminal.rs index 096e2d73..fa087adb 100644 --- a/crates/site-builder/src/components/terminal.rs +++ b/crates/site-builder/src/components/terminal.rs @@ -75,7 +75,7 @@ pub fn render_terminal() -> Markup { form id="terminal-form" style="padding: 12px 16px; background: rgba(14, 18, 25, 0.95); border-top: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 8px;" { span style="color: var(--accent-green); font-family: var(--font-mono); font-size: 14px; font-weight: 700;" { "$" } - input id="terminal-input" type="text" placeholder="Type a syscall (sys_telemetry, sys_alloc_kv, sys_vault, help)..." autocomplete="off" style="flex: 1; background: transparent; border: none; outline: none; color: var(--text-primary); font-family: var(--font-mono); font-size: 13px;" {} + input id="terminal-input" type="text" aria-label="Terminal command: Type a syscall (sys_telemetry, sys_alloc_kv, sys_vault, help)..." placeholder="Type a syscall (sys_telemetry, sys_alloc_kv, sys_vault, help)..." autocomplete="off" style="flex: 1; background: transparent; border: none; outline: none; color: var(--text-primary); font-family: var(--font-mono); font-size: 13px;" {} button type="submit" style="background: var(--accent-green); color: var(--bg-base); border: none; border-radius: 4px; padding: 6px 14px; font-family: var(--font-mono); font-size: 12px; font-weight: 700; cursor: pointer;" { "RUN" } diff --git a/crates/site-builder/src/main.rs b/crates/site-builder/src/main.rs index 4cf5e3e7..6822dc1d 100644 --- a/crates/site-builder/src/main.rs +++ b/crates/site-builder/src/main.rs @@ -224,6 +224,20 @@ fn build_pure_rust_site(dist: &Path, facts_path: &Path) { println!(" [PAGE] Emitted /{}/ (index.html)", slug); } + // Glossary: the terms of the project, each linked to where it is used. + let glossary = render_page_layout( + components::glossary::TITLE, + components::glossary::DESCRIPTION, + components::glossary::URL, + "website", + html! {}, + components::glossary::render_glossary(), + ); + fs::create_dir_all(dist.join("glossary")).expect("Failed to create glossary dir"); + fs::write(dist.join("glossary/index.html"), glossary.into_string()) + .expect("Failed to write glossary/index.html"); + println!(" [PAGE] Emitted /glossary/ (index.html)"); + // Section hubs: /experiments/, /evidence/, /philosophy/ (NARR-NAV) components::hubs::emit_hub_pages(dist); diff --git a/crates/site-builder/src/seo.rs b/crates/site-builder/src/seo.rs index 67affd60..718c08cd 100644 --- a/crates/site-builder/src/seo.rs +++ b/crates/site-builder/src/seo.rs @@ -101,6 +101,7 @@ pub const PAGES: &[PageInfo] = &[ PageInfo { path: "/post-llm-case/", name: "The Post-LLM Case", what: "The case for a different learning machine: programs proposed, verification deciding, knowledge kept as inspectable programs.", section: Section::Philosophy, kind: Kind::Article, image: "/og-philosophy.png", published: "2026-09-27", doi: None }, PageInfo { path: "/blog/", name: "Blog", what: "Research notes on building AIEN: what shipped, what the evidence says, what remains open.", section: Section::Blog, kind: Kind::Collection, image: "/og-blog.png", published: "2026-09-27", doi: None }, PageInfo { path: "/blog/aien-v3-research-plan/", name: "The AIEN V3 Research Plan", what: "The ratified V3 research plan, the Substrate Edition, with six falsifiable hypotheses.", section: Section::Blog, kind: Kind::Article, image: "/og-blog.png", published: "2026-09-27", doi: None }, + PageInfo { path: "/glossary/", name: "Glossary", what: "The terms AIENOS uses in its own sense, each linked to the page where it does real work.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-23", doi: None }, PageInfo { path: "/licensing/", name: "Licensing", what: "The one canonical licensing statement: AGPL-3.0-or-later for every repository.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-01", doi: None }, ]; @@ -129,6 +130,9 @@ pub const DATA_FILES: &[DataFile] = &[ DataFile { path: "/data/now.tsv", purpose: "The raw ledger as published: one line per item, tab separated.", schema: "Columns: id, opened_utc, owner, status, item, done_when, evidence, updated_utc.", cadence: "whenever the ledger changes", media_type: "text/tab-separated-values" }, DataFile { path: "/feed.xml", purpose: "Atom feed of the blog posts and research papers, newest first.", schema: "Atom 1.0", cadence: "when a page is published or revised", media_type: "application/atom+xml" }, DataFile { path: "/sitemap.xml", purpose: "Every page, both languages, with lastmod and hreflang alternates. Walked from the files actually written.", schema: "sitemaps.org 0.9 with xhtml:link alternates", cadence: "every build", media_type: "application/xml" }, + DataFile { path: "/sitemap.md", purpose: "The readable twin of sitemap.xml: every page grouped in H2 sections with a one-line description.", schema: "Markdown: H1, blockquote summary, H2 sections of links.", cadence: "every build", media_type: "text/markdown" }, + DataFile { path: "/AGENTS.md", purpose: "The repository brief for coding agents: installation, configuration, usage, conventions and approval boundaries.", schema: "Markdown: H1, Installation, Configuration, Usage, Conventions, Safety and approvals.", cadence: "when the build or conventions change", media_type: "text/markdown" }, + DataFile { path: "/index.md", purpose: "The front page as Markdown: the same content as the HTML, with frontmatter, the page body and a sitemap section. Every page has a mirror at the same path with .md.", schema: "Markdown: YAML frontmatter (title, description, last_updated, canonical_url), body, Sitemap section.", cadence: "every build", media_type: "text/markdown" }, DataFile { path: "/research/CITATION.cff", purpose: "Citation metadata for the Turing preprints.", schema: "Citation File Format 1.2.0", cadence: "when a paper is revised", media_type: "text/yaml" }, DataFile { path: "/research/aien-research-plan.md", purpose: "The ratified V3 research plan in Markdown.", schema: "Markdown", cadence: "when the plan is revised", media_type: "text/markdown" }, DataFile { path: "/humans.txt", purpose: "Who builds this: the person, the agents and the machines.", schema: "humanstxt.org", cadence: "rarely", media_type: "text/plain" }, @@ -277,6 +281,17 @@ pub fn info_for(en_path: &str) -> Option<&'static PageInfo> { PAGES.iter().find(|p| p.path == en_path) } +/// The markdown mirror of a page: `/` becomes `/index.md`, every other +/// directory page loses its trailing slash and gains `.md`. This is the +/// path an agent reaches by adding `.md` to the readable URL. +pub fn md_path(path: &str) -> String { + if path == "/" || path == "/zh-CN/" { + format!("{path}index.md") + } else { + format!("{}.md", path.trim_end_matches('/')) + } +} + /// Fails the build when dist and PAGES disagree. pub fn check_registry(pages: &[Emitted]) { for p in pages.iter().filter(|p| !p.is_zh()) { @@ -331,11 +346,15 @@ fn owned_tag(tag: &str) -> bool { match tag_name(tag).as_str() { "link" => { let rel = attr(tag, "rel").unwrap_or_default(); - rel == "canonical" || (rel == "alternate" && (attr(tag, "hreflang").is_some() || attr(tag, "type").map(|t| t.contains("xml")).unwrap_or(false))) + rel == "canonical" + || rel == "describedby" + || (rel == "alternate" + && (attr(tag, "hreflang").is_some() + || attr(tag, "type").map(|t| t.contains("xml") || t.contains("markdown")).unwrap_or(false))) } "meta" => { let key = attr(tag, "property").or_else(|| attr(tag, "name")).unwrap_or_default(); - key.starts_with("og:") || key.starts_with("twitter:") || key.starts_with("article:") + key.starts_with("og:") || key.starts_with("twitter:") || key.starts_with("article:") || key == "robots" } _ => false, } @@ -542,9 +561,7 @@ fn graph(page: &Emitted, info: &PageInfo, facts: &HeadFacts, has_mirror: bool, c if is_web_page { // WebPage-only properties; the validator warns when they sit on an Article. node["primaryImageOfPage"] = json!({"@type": "ImageObject", "url": image, "width": 1200, "height": 630}); - if page.path != "/" && page.path != "/zh-CN/" { - node["breadcrumb"] = json!({"@id": format!("{url}#breadcrumb")}); - } + node["breadcrumb"] = json!({"@id": format!("{url}#breadcrumb")}); } else { node["author"] = json!({"@id": format!("{HOST}/#drake")}); node["mainEntityOfPage"] = json!(url); @@ -568,7 +585,7 @@ fn graph(page: &Emitted, info: &PageInfo, facts: &HeadFacts, has_mirror: bool, c } } let mut nodes = vec![org(), author(), website(), node]; - if page.path != "/" && page.path != "/zh-CN/" { + if is_web_page || page.path != "/" { nodes.push(breadcrumb(page, &title)); } match info.path { @@ -603,6 +620,9 @@ fn head_block(page: &Emitted, info: &PageInfo, facts: &HeadFacts, has_mirror: bo let locale = if page.is_zh() { "zh_CN" } else { "en_US" }; let mut b = String::new(); b.push_str(&format!("\n")); + b.push_str(&format!("\n", md_path(&page.path))); + b.push_str(&format!("\n")); + b.push_str("\n"); if has_mirror { let en = format!("{HOST}{}", page.en_path()); let zh = format!("{HOST}{}", page.zh_path()); @@ -622,6 +642,40 @@ fn head_block(page: &Emitted, info: &PageInfo, facts: &HeadFacts, has_mirror: bo b } +fn yaml_quote(s: &str) -> String { + s.replace('\\', "\\\\").replace('"', "\\\"") +} + +/// The markdown mirror of one page: frontmatter, the page body as markdown +/// from the same HTML that was just written, and the sitemap section every +/// mirror carries so an agent can walk the rest of the site from it. +fn markdown_mirror(page: &Emitted, facts: &HeadFacts, html: &str) -> String { + let title = unescape(if facts.og_title.is_empty() { &facts.title } else { &facts.og_title }); + let description = unescape(if facts.description.is_empty() { &facts.og_description } else { &facts.description }); + let date = page.lastmod.get(..10).unwrap_or(&page.lastmod); + let mut s = String::new(); + s.push_str("---\n"); + s.push_str(&format!("title: \"{}\"\n", yaml_quote(&title))); + s.push_str(&format!("description: \"{}\"\n", yaml_quote(&description))); + s.push_str(&format!("last_updated: \"{date}\"\n")); + s.push_str(&format!("canonical_url: \"{}\"\n", page.url())); + s.push_str("---\n\n"); + s.push_str(&html_to_text(html)); + s.push_str(&format!("\n\n## Sitemap\n\nSee the full [sitemap]({HOST}/sitemap.md) for every page on aienos.com.\n")); + s +} + +/// Writes the mirror next to the page: `/index.md` for `/`, `/machine.md` +/// for `/machine/`, and the same shape under `/zh-CN/`. +fn write_markdown_mirror(dist: &Path, page: &Emitted, facts: &HeadFacts, html: &str) { + let rel = md_path(&page.path); + let file = dist.join(rel.trim_start_matches('/')); + if let Some(parent) = file.parent() { + fs::create_dir_all(parent).unwrap_or_else(|e| panic!("create {}: {e}", parent.display())); + } + fs::write(&file, markdown_mirror(page, facts, html)).unwrap_or_else(|e| panic!("write {}: {e}", file.display())); +} + /// Rewrites the head of every page in dist. Returns the pages, for the sitemap and feeds. pub fn enrich(dist: &Path, ctx: &BuildCtx) -> Vec { let pages = walk_pages(dist, ctx); @@ -644,9 +698,10 @@ pub fn enrich(dist: &Path, ctx: &BuildCtx) -> Vec { out.push('\n'); out.push_str(&block); out.push_str(&html[head_end..]); + write_markdown_mirror(dist, page, &facts, &out); fs::write(&page.file, out).unwrap_or_else(|e| panic!("write {}: {e}", page.file.display())); } - println!(" [SEO] Rewrote the head of {} pages: canonical on {HOST}, cards, hreflang, JSON-LD", pages.len()); + println!(" [SEO] Rewrote the head of {} pages: canonical on {HOST}, cards, hreflang, JSON-LD, markdown mirrors", pages.len()); pages } @@ -762,7 +817,7 @@ pub fn llms_txt(status_lines: &[String], research_sentence: &str) -> String { for l in status_lines { s.push_str(&format!("- {l}\n")); } - s.push_str(&format!("- Research: {research_sentence}\n\n")); + s.push_str(&format!("- [Research status]({HOST}/research/status/): {research_sentence}\n\n")); for sec in [Section::Machine, Section::Turing, Section::Evidence, Section::Philosophy, Section::Blog] { s.push_str(&format!("## {}\n\n", section_title(sec))); for p in PAGES.iter().filter(|p| p.section == sec) { @@ -785,6 +840,30 @@ pub fn llms_txt(status_lines: &[String], research_sentence: &str) -> String { s } +/// /sitemap.md: the readable twin of sitemap.xml, H2 sections of described +/// links, generated from the same page registry as llms.txt and the XML map. +pub fn sitemap_md() -> String { + let mut s = String::from("# Sitemap\n\n"); + s.push_str(&format!("> Every page on aienos.com, grouped the way the site is. The crawler index is [sitemap.xml]({HOST}/sitemap.xml); the file list is [data/index.json]({HOST}/data/index.json).\n\n")); + for sec in [Section::Machine, Section::Turing, Section::Evidence, Section::Philosophy, Section::Blog, Section::Optional] { + s.push_str(&format!("## {}\n\n", section_title(sec))); + for p in PAGES.iter().filter(|p| p.section == sec) { + s.push_str(&format!("- [{}]({HOST}{}): {}\n", p.name, p.path, p.what)); + } + s.push('\n'); + } + s.push_str("## Simplified Chinese\n\n"); + for p in PAGES { + s.push_str(&format!("- [{}]({HOST}/zh-CN{}): the same page in Simplified Chinese.\n", p.name, p.path)); + } + s.push_str("\n## For agents\n\n"); + s.push_str(&format!("- [llms.txt]({HOST}/llms.txt): the site in one file for AI readers.\n")); + s.push_str(&format!("- [llms-full.txt]({HOST}/llms-full.txt): every page's full text in one file.\n")); + s.push_str(&format!("- [AGENTS.md]({HOST}/AGENTS.md): how to build, test and change this site.\n")); + s.push_str(&format!("- [data/index.json]({HOST}/data/index.json): every machine-readable file with its purpose and cadence.\n")); + s +} + /// Plain text of a page body: scripts, styles, header, nav and footer dropped, /// headings marked, links kept with their targets. pub fn html_to_text(html: &str) -> String { @@ -939,10 +1018,13 @@ pub fn write_machine_surface(dist: &Path, pages: &[Emitted], now: &Now, ctx: &Bu fs::write(dist.join("now/feed.xml"), now_feed(now, ctx)).expect("write now/feed.xml"); fs::write(dist.join("llms.txt"), llms).expect("write llms.txt"); fs::write(dist.join("llms-full.txt"), llms_full(pages)).expect("write llms-full.txt"); + fs::write(dist.join("sitemap.md"), sitemap_md()).expect("write sitemap.md"); + let agents = fs::read_to_string("AGENTS.md").expect("AGENTS.md must exist at the repository root: the build publishes it at /AGENTS.md"); + fs::write(dist.join("AGENTS.md"), agents).expect("write AGENTS.md"); fs::create_dir_all(dist.join("data")).expect("data dir"); fs::write(dist.join("data/index.json"), data_index(ctx)).expect("write data/index.json"); fs::write(dist.join("humans.txt"), humans_txt(ctx)).expect("write humans.txt"); - println!(" [GEN] sitemap.xml ({} urls), robots.txt ({} named agents), feed.xml, now/feed.xml, llms.txt, llms-full.txt, data/index.json, humans.txt", pages.len(), AI_AGENTS.len()); + println!(" [GEN] sitemap.xml ({} urls), sitemap.md, AGENTS.md, robots.txt ({} named agents), feed.xml, now/feed.xml, llms.txt, llms-full.txt, data/index.json, humans.txt", pages.len(), AI_AGENTS.len()); } /// Fails the build when the machine surface is inconsistent with the pages. @@ -956,6 +1038,17 @@ pub fn verify(dist: &Path) { } assert!(robots.contains(&format!("Sitemap: {HOST}/sitemap.xml")), "robots.txt must point at the sitemap"); assert!(!sitemap.contains("https://aienos.com/"), "sitemap must use the www host"); + let sitemap_md = fs::read_to_string(dist.join("sitemap.md")).expect("sitemap.md"); + assert!(sitemap_md.starts_with("# Sitemap\n"), "sitemap.md must start with its H1"); + assert!(sitemap_md.contains("\n## "), "sitemap.md must carry H2 sections"); + assert!(sitemap_md.contains(&format!("]({HOST}/glossary/)")), "sitemap.md must link the glossary"); + let agents = fs::read_to_string(dist.join("AGENTS.md")).expect("AGENTS.md"); + for section in ["## Installation", "## Configuration", "## Usage"] { + assert!(agents.contains(section), "AGENTS.md must carry {section}"); + } + let index_html = fs::read_to_string(dist.join("index.html")).expect("index.html"); + assert!(index_html.contains("href=\"/glossary/\""), "the homepage must link the glossary"); + assert!(index_html.contains("\"BreadcrumbList\""), "the homepage JSON-LD must carry a BreadcrumbList"); for d in DATA_FILES { let rel = d.path.trim_start_matches('/'); assert!(dist.join(rel).exists(), "data index lists {} but it was not written", d.path); @@ -969,6 +1062,14 @@ pub fn verify(dist: &Path) { assert!(page.contains(&format!("", info.path)), "{} canonical must be on {HOST}", info.path); assert!(page.contains("application/ld+json"), "{} must carry JSON-LD", info.path); assert!(page.contains("twitter:site"), "{} must carry twitter:site", info.path); + let md_rel = md_path(info.path); + assert!(page.contains(&format!("")), "{} must link its markdown mirror {md_rel}", info.path); + assert!(page.contains(&format!("")), "{} must declare llms.txt via describedby", info.path); + assert!(page.contains("max-snippet:-1") && page.contains("max-image-preview:large"), "{} must carry the AI snippet directives", info.path); + let md = fs::read_to_string(dist.join(md_rel.trim_start_matches('/'))).unwrap_or_else(|_| panic!("{} markdown mirror {md_rel} missing", info.path)); + assert!(md.starts_with("---\n"), "{} markdown mirror must open with frontmatter", info.path); + assert!(md.contains("canonical_url:"), "{} markdown mirror must carry canonical_url", info.path); + assert!(md.contains("\n## Sitemap\n"), "{} markdown mirror must carry a Sitemap section", info.path); let ld_start = page.find("").expect("ld end"); let v: Value = serde_json::from_str(&page[ld_start..ld_end]).unwrap_or_else(|e| panic!("{} JSON-LD does not parse: {e}", info.path)); @@ -980,7 +1081,7 @@ pub fn verify(dist: &Path) { assert!(!text.contains('\u{2014}') && !text.contains('\u{2013}'), "dash in {}", info.path); } } - for f in ["feed.xml", "now/feed.xml", "llms.txt", "llms-full.txt", "humans.txt", "data/index.json", "sitemap.xml", "robots.txt", "404.html"] { + for f in ["feed.xml", "now/feed.xml", "llms.txt", "llms-full.txt", "humans.txt", "data/index.json", "sitemap.xml", "sitemap.md", "AGENTS.md", "index.md", "robots.txt", "404.html"] { let t = fs::read_to_string(dist.join(f)).expect(f); assert!(!t.contains('\u{2014}') && !t.contains('\u{2013}'), "dash in {f}"); } @@ -1005,6 +1106,9 @@ mod tests { assert!(owned_tag(t)); assert!(!owned_tag("")); assert!(owned_tag("")); + assert!(owned_tag("")); + assert!(owned_tag("")); + assert!(owned_tag("")); assert!(!owned_tag("")); } @@ -1059,6 +1163,32 @@ mod tests { assert!(t[opt..].contains("/licensing/")); } + #[test] + fn markdown_mirror_paths_follow_the_public_convention() { + assert_eq!(md_path("/"), "/index.md"); + assert_eq!(md_path("/machine/"), "/machine.md"); + assert_eq!(md_path("/zh-CN/"), "/zh-CN/index.md"); + assert_eq!(md_path("/zh-CN/machine/"), "/zh-CN/machine.md"); + assert_eq!(md_path("/research/status/"), "/research/status.md"); + } + + #[test] + fn discovery_files_link_every_list_item_in_an_h2_section() { + for (name, doc) in [ + ("llms.txt", crate::components::status::llms_txt()), + ("sitemap.md", sitemap_md()), + ] { + let mut in_h2 = false; + for line in doc.lines() { + if line.starts_with("## ") { + in_h2 = true; + } else if in_h2 && line.starts_with("- ") { + assert!(line.contains("]("), "{name} has an unlinked item in an H2 section: {line}"); + } + } + } + } + #[test] fn html_to_text_keeps_headings_links_and_drops_chrome() { let h = "x
NAV

Title

Para with a link and more.

  • one
  • two
";