fix(afdocs): add llms.txt directive to OpenAPI mirrors; drop mcp.json from llms.txt#6
Open
fix(afdocs): add llms.txt directive to OpenAPI mirrors; drop mcp.json from llms.txt#6
Conversation
… from llms.txt Clears two AFDocs warnings flagged by `npx afdocs check https://docs.atomicmemory.ai` against PR #5 (round-2): ## llms-txt-directive-md (was 28/49 pages, 21 missing) OpenAPI page mirrors are rendered from the vendored OpenAPI YAML in `scripts/mirror-markdown.mjs`, not from rendered HTML, so the remark plugin's directive injection never reached them. Their existing "Machine-readable: this page mirrors operation X" blockquote also didn't satisfy the AFDocs spec, which requires a blockquote that links to llms.txt. Both `renderOpenapiOperation` and `renderOpenapiInfo` now emit `> Agent index: [llms.txt](/llms.txt)` as their first blockquote (matching what the remark plugin injects on hand-authored pages), and move the operation/info source-of-truth note to a regular paragraph below. ## llms-txt-directive-html (was 49/50 pages, 1 missing) The "missing" page was `/.well-known/mcp.json` — a JSON file that AFDocs followed because llms.txt linked it as a documentation entry. JSON files don't have an HTML directive blockquote, so listing it as a doc link was a false positive against the directive check. `build-llms-txt.mjs` no longer emits `.well-known/mcp.json` as a markdown link in the Optional section. Discovery for the MCP descriptor is via the well-known path itself; agents that care will look at `/.well-known/mcp.json` directly. A short non-link line in llms.txt still tells humans/agents the descriptor exists. ## Out of scope - content-start-position (16 of 50 pages past 50%, all OpenAPI ref pages): the DOM has `<aside>` (sidebar) before `<article>`, and for short OpenAPI operation pages the sidebar text outweighs the article body — pushing the first content element past 50% in the HTML→text conversion. Real fix is a Docusaurus theme swizzle to reorder DOM (CSS keeps visual layout). Not in this PR. - markdown-content-parity (~9 of 49 pages, avg 6% missing, improvement from PR #5's avg 13%): residual gap is mostly whitespace tokenization differences in code blocks; the spec threshold is 5% pass / 20% warn / >20% fail. Real wins from here require either turndown rule tuning or `data-markdown-ignore` annotations on theme elements. Not in this PR. - content-negotiation (FAIL): GH Pages cannot honor `Accept: text/markdown`. Tracked as F1 (hosting migration).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Round 3 of AFDocs fixes — directive coverage
Overview
Real AFDocs scorecard against the live site (after PR #5) shows 93/100 (A) with 4 remaining issues. This PR clears the 2 directive-coverage warnings — quick wins that close low-hanging gaps. The other 2 (content-start-position, markdown-content-parity residual, content-negotiation) need deeper work and are explicitly out of scope below.
llms-txt-directive-mdllms-txt-directive-htmlcontent-start-positionmarkdown-content-paritycontent-negotiationChanges
Add directive to OpenAPI mirrors
scripts/mirror-markdown.mjs—renderOpenapiOperationandrenderOpenapiInfonow emit> Agent index: [llms.txt](/llms.txt)as the first blockquote (same wording the remark plugin injects on hand-authored pages). The "this page mirrors operation X" note moves to a regular paragraph below.OpenAPI .md mirrors render from the vendored YAML, so the remark plugin's directive injection (which runs on MDX) never reached them. ~30 API operation pages plus the rolled-up info page were missing the directive in their .md form.
Drop
.well-known/mcp.jsonfrom llms.txtscripts/build-llms-txt.mjs— the "Optional" section listed.well-known/mcp.jsonas a markdown link, so AFDocs walked it as a doc page and flagged it for missing the HTML directive. Now a non-link prose line in llms.txt mentions the descriptor exists; agents that care will look at the well-known path directly.Out of scope
content-start-position(16/50, worst 69%)Almost entirely OpenAPI reference pages. Diagnosis:
For short operation pages (e.g.
GET /v1/memories/{id}) the sidebar's text content outweighs the article body, so the first meaningful content element lands past 50% in the converted text.Fix requires a Docusaurus theme swizzle of the docs layout to render
<article>before<aside>in DOM, with CSS preserving visual sidebar-on-left layout. That's a separate, larger change touching theme components.markdown-content-parity(9/49, avg 6%, max 42%)PR #5 already brought avg 13% → 6% by switching to HTML→md rendering with cheerio + turndown + GFM. The residual gap is dominated by whitespace tokenization in code blocks (turndown joins Prism
.token-linechildren with\nbut inline tokens don't always have spaces between them, so word-level diff over-counts gaps).Further wins from here need either turndown rule tuning per code-language, or theme-level
data-markdown-ignoreattributes on elements that exist only in HTML. Bigger investment than the round-3 directive fixes.content-negotiation(FAIL)GH Pages cannot honor
Accept: text/markdown. F1 follow-up: migrate hosting to Cloudflare Pages / Vercel / Netlify with an edge function for the rewrite.Verification
npm run buildcleannpm run typecheckclean.mdmirrors now lead with> Agent index: [llms.txt](/llms.txt).well-known/mcp.json🤖 Generated with Claude Code