Skip to content

feat: serve markdown to agents via content negotiation - #28

Merged
atinux merged 7 commits into
mainfrom
feat/agent-friendly-markdown
Aug 24, 2026
Merged

feat: serve markdown to agents via content negotiation#28
atinux merged 7 commits into
mainfrom
feat/agent-friendly-markdown

Conversation

@atinux

@atinux atinux commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Improves the is-agentic score for comark.dev (currently 67/100) for every site built on this layer.

Written by an AI agent (OpenCode), reviewed by @atinux.

What changed

Markdown content negotiation (essential check, was failing)

  • New modules/markdown-rewrite.ts injects rewrites into .vercel/output/config.json after Nitro compiles, same approach as Docus' markdown-rewrite.
  • Accept: text/markdown (or a curl/* user-agent) on any production page URL serves its /raw/** mirror; / serves /llms.txt. Responses carry content-type: text/markdown and vary: Accept.
  • Rewrites happen at the routing layer, before the ISR cache, so HTML and markdown variants are cached under different paths and can't poison each other. Docus enumerates pages from a prerendered llms.txt; this layer reads content at request time, so the rewrites use generic patterns instead (unit-tested in test/markdown-rewrite.test.ts).
  • Versioned previews (/tree, /blob, /pr) are excluded and serve HTML only: they are review surfaces, not agent-facing content, and mirroring them would mean re-implementing the preview authorization from feat: authorize commit previews and add /pr/:number preview routes #31 on every raw route. An earlier revision of this PR shipped preview mirrors; they were dropped after feat: authorize commit previews and add /pr/:number preview routes #31 landed.

Agent-friendly 404s (essential check, was partial)

  • /raw/** misses return a real 404 with a short markdown body pointing at /llms.txt, /llms-full.txt, /raw/index.md, and the sitemap. Combined with the rewrites, an agent that guesses a wrong page URL gets a recoverable markdown 404.

llms.txt agent guidance (recommended check)

  • No new key: the existing docs.llms.description (the llms.txt blockquote summary, where the spec puts key context) is now documented as the place for "when to use" guidance. An earlier revision added a docs.llms.whenToUse key and a custom section; dropped since the spec has no such section.

Organization JSON-LD (recommended check)

  • New docs.schemaOrg.organization sub-key, emitted as a top-level Organization node on the landing page (for contactPoint, address, sameAs).

Docs

  • New Markdown for agents section, updated configuration reference with an "Agent metadata" example, clarified in versioned-previews and the preview-versions skill that mirrors cover production pages only.

Verification

  • pnpm lint (no new warnings), pnpm test (146 passed), pnpm typecheck clean.
  • NITRO_PRESET=vercel pnpm build → 4 routes injected into config.json (verified shape).
  • Note: the vercel build logs a pre-existing, non-fatal EISDIR during prerender of /.well-known/skills (from the skills module, unrelated to this PR).

Out of scope (needs changes in the comark.dev content repo)

  • "Flat heading structure" finding: comark.dev's homepage SSR has h1/h2/h3, but the hero demo renders a second <h1 id="hello-world"> which likely confuses the scanner.
  • Trust pages (/about, /contact, /privacy), docs.llms.description / organization values, OpenAPI spec decision.

Vercel routing-layer rewrites (Docus-style) send Accept: text/markdown
and curl requests to the /raw/** mirrors, ahead of the ISR cache.
Adds raw mirrors for /tree and /blob previews, markdown 404 bodies with
recovery links, an llms.txt when-to-use section, and an Organization
JSON-LD node.
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comark-docs-layer Ready Ready Preview Aug 24, 2026 1:34pm

@pkg-pr-new

pkg-pr-new Bot commented Aug 22, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/comarkdown/comark-docs@28

commit: 27d2980

@atinux
atinux requested a review from larbish August 24, 2026 08:36
atinux added 2 commits August 24, 2026 14:05
…arkdown

# Conflicts:
#	playground/content/3.concepts/2.versioned-previews.md
Preview pages (/tree, /blob, /pr) serve HTML only: the raw mirrors and
content negotiation now cover production pages exclusively. Previews are
review surfaces, not agent-facing content, and mirroring them would have
required re-implementing the preview authorization added in #31 on every
raw route.

- delete /raw/tree and /raw/blob routes
- exclude /tree, /blob and /pr from the markdown rewrites
- restore the prod-only guard on the Copy page / Open in Chat actions
- align docs and the preview-versions skill
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

The llms.txt spec has no "when to use" section: the blockquote summary
under the H1 is where key context belongs. Drop the invented
docs.llms.whenToUse key and document putting the guidance in
docs.llms.description instead.
@atinux
atinux merged commit 1d0b9f7 into main Aug 24, 2026
4 of 5 checks passed
@atinux
atinux deleted the feat/agent-friendly-markdown branch August 24, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant