Skip to content

feat(hub): production agent docs, changelog channel & richer hub rendering - #1839

Merged
itomek merged 15 commits into
mainfrom
feat/hub-changelog-docs-rendering
Jun 24, 2026
Merged

itomek merged 15 commits into
mainfrom
feat/hub-changelog-docs-rendering

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Why this matters

The Agent Hub rendered README markdown through a renderer that emitted dead gaia-* Tailwind classes (the theme only defines g-*), so docs read poorly and leaked white headings into the light theme; there was no changelog on the hub; and the email agent shipped two drifting READMEs plus a broken pip install tab (it isn't on PyPI). This makes the hub presentable for handing a packaged agent to an external integration team: one canonical, production-grade README, a real changelog channel, npm-aware install, and a Mintlify-style reading experience.

What's in it

  • Markdown rendering (Mintlify-style). The renderer now emits classless semantic HTML and a single .doc prose theme owns presentation (ruled h2, dark code cards, bordered tables, <hr>). Adds Prism syntax highlighting, a standalone-diagram lightbox, and README/Changelog doc tabs.
  • Changelog channel, end to end. Worker /publish accepts an optional changelog part → stored per-version → into index.json → rendered in the Changelog tab. gaia agent init now scaffolds CHANGELOG.md; --lint warns when README/CHANGELOG is missing; gaia agent publish attaches it.
  • npm-distribution UX. New optional manifest fields npm_package + playground_url thread through the Worker into the catalog. The email page now shows npm-only install (the broken pip/Source tabs are gone), an in-README playground launcher, and hides placeholder-zero requirement rows (e.g. "Disk 0 GB").
  • Email-agent docs (production handoff). Consolidated to one canonical README (what the agent does + the integration interface + troubleshooting), plus SPEC.md (full reference) and SKILL.md (Claude Code integration playbook), shipped in the npm tarball. Four adversarial critique rounds hardened it — CORS/renderer, server concurrency & lifecycle, errors→retries, headless send 403/503; deleted the redundant python README.

Test plan

  • Worker: cd workers/agent-hub && npm test (60 pass) + npx tsc --noEmit
  • Website: cd website && npx vitest run (14) + npx astro check (0 errors) + HUB_CATALOG_URL=https://hub.amd-gaia.ai npm run build
  • npm client: cd hub/agents/npm/agent-email && npm run build && npm test (32)
  • Python: pytest tests/unit/test_cli_agent.py tests/unit/test_hub_publisher.py hub/agents/python/email/tests/test_stamp_version.py
  • Hub /hub/email: npm install tab, README/Changelog tabs, highlighted code, click-to-zoom diagram, no placeholder requirement rows

…endering

Before: the hub rendered agent README markdown through a renderer that emitted
dead `gaia-*` Tailwind classes (the theme only defines `g-*`), so docs read
poorly and leaked white headings into the light theme; there was no changelog on
the hub; the email agent shipped two drifting READMEs and a broken `pip install`
tab (it is not on PyPI). After: one canonical, integration-focused README plus a
SPEC + SKILL, a changelog channel end to end, and a Mintlify-style prose theme.

- Hub Worker: optional `changelog` part on /publish, stored per-version and
  carried into index.json (storage/publish/catalog/types/schema + tests).
- Website: Mintlify-style `.doc` prose theme (renderer now emits classless
  semantic HTML); Changelog section; npm-only install for npm-distributed agents;
  hide placeholder-zero requirement rows; standalone-diagram lightbox.
- Email docs: consolidate to one README (leads with what the agent does, focuses
  on the integration interface + troubleshooting), add SPEC.md (full reference) and
  SKILL.md (Claude Code integration playbook), shipped in the npm tarball. Delete
  the redundant python README + its dead pyproject readme field and stamp rule.
- Authoring: `gaia agent init` scaffolds CHANGELOG.md; `--lint` warns when
  README/CHANGELOG is missing; `gaia agent publish` attaches CHANGELOG.
Critique pass for a team integrating the package into a production web app:

- README: add a 'Running in production' section (spawn once at boot, fetchBinary
  as a build step, single-Lemonade-slot concurrency, port conflicts, no
  auto-restart, SIGTERM->shutdown) and an errors-and-retries table keyed on status.
- Fix the renderer story: the sidecar serves same-origin/no-CORS, so a renderer
  can't call it cross-origin — document the Electron main-process/IPC proxy pattern
  in README/SPEC/SKILL instead of a direct fetch.
- State 'send' returns 503 on a headless server (no mailbox connector); qualify the
  privacy claim (triage/draft stay on-device, send transmits to the provider); tie
  the 8 GB requirement to the local model.
- Strip stale internal refs (#1648/#1262/'spike'/'pending R2') from shipped source
  comments and user-facing error/CLI strings — R2 is wired, so they were wrong too.

npm build clean, 32 tests pass.
Round-3 critique caught a real defect: the README said send 'takes no token',
which contradicted its own interface table and the source. send requires the
single-use confirmation token from draft — a missing/invalid token is rejected
with 403 *before* the mailbox checks (api_routes.py: "an invalid or missing
confirmation token raises a 403"). Document the full ladder (403 → 503 → 400)
consistently across README, SPEC, and SKILL.
- Tabbed doc area on the agent page: switch between the rendered README and
  Changelog (replaces the always-on bottom changelog section).
- Syntax highlighting: the markdown renderer emits a sanitized `language-*` class
  per fenced block, highlighted client-side with Prism (ts/js/bash/json) under a
  token theme tuned for the dark code card.
The website already reads npm_package (npm-only install) and playground_url (the
playground launcher) from the catalog, but the Worker never emitted them — so they
only worked against an injected catalog. Parse both optional manifest fields and
carry them into index.json (manifest/types/catalog/schemas + tests), and declare
them on the email agent's manifest. Now a real publish lights up the npm install
method and the in-README playground link on the live hub.

Worker: 60 tests pass, tsc clean.
@kovtcharov
kovtcharov requested a review from itomek-amd June 24, 2026 06:14
@kovtcharov kovtcharov added agent-hub Agent Hub: discovery, install, and distribution agent-hub-agent A Hub agent package labels Jun 24, 2026
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes website GAIA website (amd-gaia.ai) labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Review — feat(hub): production agent docs, changelog channel & richer hub rendering

Verdict: Request changes — one fix worth making here; everything else is merge-ready.

This is a strong, well-tested hub upgrade: a changelog channel wired end-to-end (Worker /publish → R2 → index.json → rendered tab), npm-aware install on the hub page, a Mintlify-style reading experience, and the email-agent docs consolidated to one canonical README + SPEC + SKILL. Test coverage is genuinely good.

The one thing to fix: the markdown renderer corrupts numbers written in prose. Any <number> with spaces around it gets mangled — 8 GB renders as undefinedGB, HTTP 502 until as HTTPundefineduntil, port 8131 as undefined. This shows up on the very email hub page this PR is meant to showcase (the README's "Memory: 8 GB" line renders as "Memory:undefinedGB"). It's a pre-existing bug — not introduced here — but this PR ships the content that trips it and its whole goal is presentable production docs, so it's worth fixing in the same change. The fix is small (a non-colliding placeholder) plus one regression test.

No security concerns. The renderer is the untrusted-markdown → HTML boundary and shows up as binary in the diff, so I read it directly: escape-first, scheme-allowlisted links/images, quote-stripping, and the Prism/lightbox client scripts only reuse already-escaped/allowlisted values — no new injection surface.

🔍 Technical details

Issues

🟡 Renderer corrupts numbers-in-prose: 8 GB → undefinedGB (website/src/data/markdown.ts:38-41, :64)

renderInline stashes code spans behind a ` ${codeSpans.length - 1} ` placeholder (space-digit-space), then restores them at the end with out.replace(/ (\d+) /g, (_m, i) => codeSpans[Number(i)]). That restore regex also matches ordinary numbers in the prose. When the matched digit isn't a valid code-span index (the common case), codeSpans[n] is undefined and gets stringified into the output.

Reproduced on actual shipped content from this PR's README.md/SPEC.md:

"Memory: 8 GB — sized for the default local model"   → "Memory:undefinedGB — …"
"no mailbox connected on the host → 503"             → "…on the host →undefined"
"the first triage returns HTTP 502 until Lemonade"   → "…returns HTTPundefineduntil Lemonade"

There are 8 such <digit(s)> spans in the new email docs alone, so the flagship hub.amd-gaia.ai/hub/email page renders visibly broken text. This is pre-existing (the pre-PR renderer used the same placeholder scheme), but the rewrite was the moment to catch it and the new content is what surfaces it.

Fix — use a sentinel that can't occur in prose, and restore by that sentinel:

function renderInline(text: string): string {
  const codeSpans: string[] = [];
  // U+E000/U+E001 are Private-Use; they never appear in real markdown, so the
  // restore can't collide with ordinary numbers like "8 GB" or "port 8131".
  let out = text.replace(/`([^`]+)`/g, (_m, code) => {
    codeSpans.push(`<code>${escapeHtml(code)}</code>`);
    return `${codeSpans.length - 1}`;
  });

  out = escapeHtml(out);
  out = out.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
  // …images / links unchanged…
  out = out.replace(/(\d+)/g, (_m, i) => codeSpans[Number(i)]);
  return out;
}

(A one-click suggestion block isn't possible — git serves this file as binary in the diff, so it isn't on a reviewable diff line.) Please add a markdown.test.ts case like renderInline("up to 8 items") to lock the regression out, since the current 14 website tests don't cover it.

🟢 Architecture image pinned to a mutable branch (hub/agents/npm/agent-email/README.md:107) — the diagram now loads from raw.githubusercontent.com/amd/gaia/**main**/…/architecture.webp. That's why the stamp_version.py image rules could be dropped (consistent), but a main URL is mutable: moving/renaming the asset silently breaks the published listing's image. Acceptable for now; a tagged/commit-pinned raw URL would be more durable.

🟢 Minor a11y on the new tabs/lightbox (website/src/pages/hub/[id].astro) — the role="tablist" tabs have no roving tabindex/arrow-key handling, and the role="dialog" lightbox doesn't trap or restore focus. Non-blocking, but easy wins if you're polishing the reading experience.

Strengths

  • Changelog channel is clean and well-tested. The optionalMarkdownPart helper de-dups the readme/changelog parsing, normalizes CRLF→LF, and fails loudly on a present-but-empty part (workers/agent-hub/src/publish.ts:62). The POST /publish — CHANGELOG and npm_package & playground_url suites cover store/serve/index/empty-reject/latest-wins — exactly the right cases.
  • Consistent cleanup, no loose ends. Deleting the python README is matched by removing readme= from pyproject.toml, dropping the two stamp_version.py image rules, and pruning the now-dead test_stamp_version.py assertions. The new manifest fields are threaded all the way through (Worker parseManifest → IndexEntry → JSON schemas → website catalog.ts), and the Python manifest parser ignores unknown top-level keys so the email manifest's npm_package/playground_url won't break gaia agent lint/publish.
  • Security-aware rendering. installMethods derives channels from the manifest (never README markup), the renderer keeps its escape-first + scheme-allowlist contract, and the lightbox/Prism scripts are explicit that they reuse already-sanitized values.
  • Docs reflect the real surface. The send 403→503 gate ordering, headless-server caveat, and "everything except send is standalone" framing are accurate to api_routes.py.

…size

Round-5 fresh-lens critiques (copy-paste/compile + cross-doc consistency) came
back clean except two facts: the README 'last updated' stamp was a day in the
future (2026-06-24 → 2026-06-23), and '~31 MB' understated the Windows binary
(published artifacts are 32-43 MB) — now a per-platform range.
…e sidecar)

Empirical round — booted the real sidecar (v0.2.1) and exercised every documented
endpoint. Most claims held (GET routes 200, triage returns result.category/summary,
missing/invalid send token -> 403, valid token + no mailbox -> 503), but two real
gaps surfaced that six reading-only rounds missed:

- 'to' (and triage's from/principal) are address OBJECTS { email, name? }, not
  strings — the prior 'wraps your (to, subject, body)' wording 422s if you pass a
  string. Documented the shape + a verified draft->send round-trip in SPEC, and
  corrected the README/SKILL.
- SKILL's '`send` has no token parameter' contradicted its own table and the 403
  gate; rewritten to distinguish the required confirmation_token (403) from OAuth
  (none — host-resolved, 503 when no mailbox).

The added draft->send example was run against the sidecar: draft 200 -> send with
the token reaches 503 (not 403), confirming the token round-trip.
The empirical round hardened the request side but left the response side vague —
the docs showed only result.category/summary, yet triage is the primary surface
and an integrator routes on the full result. Added a 'Triage response shape' table
to SPEC documenting EmailTriageResult per types.ts: the exact uppercase category
enum (URGENT/NEEDS_RESPONSE/FYI/PROMOTIONAL/PERSONAL), is_spam/is_phishing,
action_items, suggested_action (reply/none/archive), draft, and usage.
…aragraph)

Found by rendering the README through the hub's own markdown renderer (not
GitHub's): the renderer only supported '-'/'*' bullets, so the README's numbered
Prerequisites (1. … 2. …) collapsed into a single <p> with literal '1.'/'2.' text
on the hub page. Add <ol> support (mirrors the <ul> lazy-continuation logic;
switching marker type starts a new list) so numbered steps in any agent README
render correctly. The .doc ol theme was already in place. +2 renderer tests.
Second hub-rendering gap from the same angle: the renderer only handled
**bold**, so the README's *italic* (e.g. *Settings → Connectors*) showed literal
asterisks on the hub. Add *...* -> <em> after the bold pass (so **x** is already
consumed); underscores are deliberately left alone so identifiers like
suggested_action survive. +1 test.
…e dead)

Third hub-rendering gap from the same angle: the README links to
[...](#browser--electron-renderer), but the renderer emitted headings with no id,
so that anchor went nowhere on the hub (works on GitHub, which auto-slugs). Add a
slug per heading matching GitHub's algorithm — drop markers, lowercase, strip to
[a-z0-9 -], replace each space with a hyphen (so 'Browser / Electron renderer' ->
'browser--electron-renderer', double hyphen). +1 test.
@github-actions

Copy link
Copy Markdown
Contributor

🟡 The new README/Changelog tab widget is missing the ARIA wiring that associates tabs with their panels. Screen readers announcing role="tab" expect either aria-controls="<panel-id>" on each button pointing to the corresponding role="tabpanel" element, or aria-labelledby="<tab-id>" on each panel pointing back. Neither is present, so assistive technology won't know which panel belongs to which tab. The WAI-ARIA 1.2 Tab pattern also requires Left/Right arrow key navigation between tabs — the JS only handles click.

🔍 Technical details

File: website/src/pages/hub/[id].astro, the tab markup + JS added in this push.

Minimum fix — add ids and aria-controls:

<button type="button" role="tab"
  id="tab-readme" aria-controls="panel-readme"
  data-doc-tab="readme" aria-selected="true" class="doc-tab">README</button>
<button type="button" role="tab"
  id="tab-changelog" aria-controls="panel-changelog"
  data-doc-tab="changelog" aria-selected="false" class="doc-tab">Changelog</button>
<article role="tabpanel" id="panel-readme"
  aria-labelledby="tab-readme" data-doc-panel="readme" class="doc max-w-[70ch]">
<article role="tabpanel" id="panel-changelog"
  aria-labelledby="tab-changelog" data-doc-panel="changelog" class="doc max-w-[70ch]" hidden>

Arrow-key navigation (add inside the tab addEventListener block):

tabRoot.addEventListener('keydown', (e) => {
  const i = tabs.indexOf(document.activeElement as HTMLButtonElement);
  if (i === -1) return;
  if (e.key === 'ArrowRight') { tabs[(i + 1) % tabs.length].focus(); e.preventDefault(); }
  if (e.key === 'ArrowLeft')  { tabs[(i - 1 + tabs.length) % tabs.length].focus(); e.preventDefault(); }
});

These two changes bring the widget up to WCAG 2.1 AA / WAI-ARIA 1.2.

CRITICAL, found by rendering the actual page in a browser (not just inspecting
HTML): the renderer parked code spans as the placeholder ' <index> ' (a
space-wrapped number), then restored with / (\d+) /g — which ALSO matched literal
numbers in prose. So '`HttpError` 502' rendered as 'HttpError undefined' (502 ->
codeSpans[502]), '`HttpError` 0' duplicated the code span, and 'Memory: 8 GB'
became 'undefinedGB'. The email README's entire Errors-&-retries table (the
502/403/503/400 codes an integrator relies on) and the RAM requirement were
corrupted on the hub. Fix: park code spans behind control-char sentinels (\u0000
… \u0001) that can't occur in prose. +1 regression test; verified in-browser.
Found by an accessibility/keyboard audit (comparing against the hub's own
InstallMethods tabs, which are ARIA-correct): the README/Changelog doc tabs I
added were missing tab id/aria-controls, panel id/aria-labelledby, roving
tabindex, and ArrowLeft/Right navigation — a regression vs the established
pattern (a screen-reader/keyboard user couldn't navigate them properly). Wire
them to the same WAI-ARIA tablist standard; verified in-browser (ArrowRight moves
selection + focus, panels announce their tab name).
…solute)

Found by checking where the links actually resolve in the live hub page: the
README's [SPEC.md]/[SKILL.md]/[CHANGELOG.md] used relative paths (./SPEC.md),
which work as sibling files on GitHub/npm but on the hub resolve to /hub/SPEC.md
— a 404, since the hub renders only the README (not those files). A developer
clicking them on hub.amd-gaia.ai/hub/email hit dead links. Point them at absolute
GitHub URLs (same main convention the architecture image uses) so they resolve on
the hub, GitHub, and npm alike. (Also verified the architecture diagram loads: 200.)
@github-actions

Copy link
Copy Markdown
Contributor

🟡 The README article gets role="tabpanel" unconditionally, but its controlling tab (id="doctab-readme") only renders when a changelog is present — so the majority of agent hub pages (no changelog) end up with an orphaned tabpanel that violates ARIA. Screen readers will encounter a tabpanel whose aria-labelledby target doesn't exist.

The tablist block is guarded by {changelogHtml && ...}, but the article on line 118 is not:

{changelogHtml && (
  <div role="tablist" ...>   {/* tab buttons — conditional */}
    <button id="doctab-readme" ...>README</button>
    ...
  </div>
)}
<article role="tabpanel" aria-labelledby="doctab-readme" ...>  {/* ← always present */}

Fix: strip role/aria-labelledby/id from the article when !changelogHtml, or wrap the assignment conditionally:

<article
  {...(changelogHtml ? { role: 'tabpanel', id: 'docpanel-readme', 'aria-labelledby': 'doctab-readme' } : {})}
  data-doc-panel="readme"
  class="doc max-w-[70ch]"
>
🔍 Technical details

website/src/pages/hub/[id].astro:118 — the article always carries role="tabpanel" and aria-labelledby="doctab-readme", but the tab with id="doctab-readme" (inside the {changelogHtml && ...} block, line 112–117) is absent for any agent with no changelog. Per ARIA 1.2 the tabpanel role requires an owned tab element; a dangling aria-labelledby reference renders the region unlabelled on assistive technology.

The data-doc-panel attribute and the JS tab-switcher are harmless when no tabs are present — the script's tabRoot.querySelectorAll('[data-doc-tab]') returns an empty array. The problem is purely the unconditional ARIA role.

…iew)

Addresses the reviewer's remaining a11y note on the image lightbox: it's
role=dialog but didn't manage focus. Now aria-modal, focusable, and on open it
moves focus into the dialog + remembers the trigger; Escape/click closes and
restores focus to the image that opened it; Tab is trapped (the dialog has no
other focusable children). The zoomable diagrams are also made keyboard-operable
(tabindex=0, role=button, Enter/Space) since they're interactive.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Thanks — all review points addressed (the blocker and both a11y notes):

  • 🟡 Renderer corrupting numbers in prose (8 GB → undefinedGB) — fixed in cd425c50. Switched the code-span placeholder to control-char sentinels that can't occur in prose (the non-colliding-placeholder approach you suggested), and added the regression test (preserves literal numbers after a code span in markdown.test.ts). Verified in-browser: the email README's Errors table now shows the real 502/403/503/400 and Memory: 8 GB, no undefined.
  • 🟡 Doc tabs missing ARIA wiring + arrow keys — fixed in 540a5327. Tabs now carry id + aria-controls; panels carry id + aria-labelledby; added roving tabindex and ArrowLeft/Right navigation. Verified in-browser (ArrowRight moves selection + focus; panels announce their tab name).
  • 🟢 Lightbox focus — fixed in f83c97e0. The dialog is now aria-modal, focusable, moves focus in on open, restores it to the triggering image on close, and traps Tab. The zoomable diagrams are also keyboard-operable (tabindex=0, role=button, Enter/Space).
  • 🟢 Architecture image pinned to main — keeping as-is: it's consistent with the in-repo raw-image convention already established for this agent (fix(agent-email): use in-repo raw image for README architecture diagram #1833), and the same main base now also serves the README's cross-doc links (2cac34cc). A commit/tag-pinned raw URL would be more durable — noting it as future hardening, not blocking this PR.

All website tests pass and astro check is clean (0 errors / 0 warnings).

@itomek
itomek added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit f8342e8 Jun 24, 2026
36 checks passed
@itomek
itomek deleted the feat/hub-changelog-docs-rendering branch June 24, 2026 13:44
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jun 24, 2026
…card (amd#1846)

## Why this matters

Trying the email agent meant a multi-step dance — fetch the binary,
spawn the sidecar, find the localhost URL, open it. This makes it **one
command** (`npx @amd-gaia/agent-email playground`) and surfaces it on
the hub agent page with a copy-the-command card whose **Open
playground** button goes live the moment the local sidecar is reachable.

A static web page **can't start a local process**, so this is the
meet-in-the-middle: a one-command launcher in the CLI + a smart button
on the page that detects when the sidecar is up.

## What's in it

- **npm CLI** — new `playground` command: `fetchBinary` → `startSidecar`
→ open the default browser to `/v1/email/playground` → run until Ctrl+C
(auto-reaped on exit). Flags: `--port` (default 8131), `--out` (binary
cache dir), `--no-open`.
- **Hub agent page** — a Playground card: the one-liner with a copy
button, plus an **Open playground** button gated by a **live liveness
probe** of the local sidecar (a `no-cors` fetch resolves if it's up,
rejects if not; `127.0.0.1` is a trustworthy origin so the HTTPS hub may
probe/link it). Shown only for npm agents that declare a
`playground_url` (from amd#1839).
- **Docs synced** (README/SPEC/SKILL/CHANGELOG) per the doc-sync rule
(amd#1842).

## Test plan

- [ ] npm: `cd hub/agents/npm/agent-email && npm run build && npm test`
(36); `node dist/cli.js help` lists `playground`
- [ ] Website: `cd website && npx astro check` (0 errors) + `npx vitest
run` (19) + build
- [ ] Hub agent page: Playground card shows the command (copy works) +
an Open button that activates only once the local sidecar responds
- [ ] End-to-end (needs the published binary): `npx
@amd-gaia/agent-email playground` fetches, starts the sidecar, and opens
the playground
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-hub Agent Hub: discovery, install, and distribution agent-hub-agent A Hub agent package devops DevOps/infrastructure changes tests Test changes website GAIA website (amd-gaia.ai)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants