Skip to content

Markdown for agents: Accept text/markdown negotiation#43

Draft
baanish wants to merge 1 commit intomainfrom
cursor/markdown-for-agents-9eae
Draft

Markdown for agents: Accept text/markdown negotiation#43
baanish wants to merge 1 commit intomainfrom
cursor/markdown-for-agents-9eae

Conversation

@baanish
Copy link
Copy Markdown
Owner

@baanish baanish commented Apr 18, 2026

Summary

Implements Markdown for Agents–style content negotiation for this static export: when Accept prefers text/markdown over HTML, Node-based servers return Markdown with Content-Type: text/markdown; charset=utf-8, Vary: Accept, and x-markdown-tokens (rough estimate from body length).

Changes

  • Shared module selfhosted/markdown-for-agents.ts: Turndown conversion, Accept parsing (ties favor HTML), 2 MB HTML cap aligned with Cloudflare docs.
  • scripts/serve-export.mjs: For GET .html files, returns markdown when negotiated; loads compiled helper from selfhosted/dist/ after npm run build.
  • selfhosted/server.ts: Same for static files and UUID viewer pages; markdown error pages when appropriate.
  • postbuild: tsc -p selfhosted/tsconfig.json so preview always has selfhosted/dist/markdown-for-agents.js.
  • Tests: Vitest unit tests; Playwright API test for negotiation; playwright.config sets Accept to prefer HTML so UI tests still load the app; goToHash waits until window.location.hash matches (fixes rare flake).
  • Docs: README, deployment, architecture, testing, AGENTS.md, self-hosted skill.

Note on Cloudflare

Zones with Cloudflare "Markdown for Agents" enabled may convert at the edge; this origin logic covers static hosts, preview, and self-hosted deployments.

Verification

  • npm run check
  • npm run test:e2e
Open in Web Open in Cursor 

- Add shared Turndown-based HTML→markdown helpers and token estimate header
- Serve markdown from static preview and self-hosted servers when markdown wins Accept
- Run selfhosted TypeScript compile after next build (postbuild); trim Docker duplicate tsc
- Playwright: prefer HTML Accept for UI tests, poll until hash applies, add API negotiation test
- Refresh visual snapshots; document behavior in README, deployment, architecture, skills

Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23b6256e-1d19-498a-885d-715b8174ada3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/markdown-for-agents-9eae

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying agent-render with  Cloudflare Pages  Cloudflare Pages

Latest commit: dd70aa3
Status: ✅  Deploy successful!
Preview URL: https://3fc67807.agent-render.pages.dev
Branch Preview URL: https://cursor-markdown-for-agents-9.agent-render.pages.dev

View logs

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.

2 participants