{"_id":"@adhenawer-pkg/markdown-edge-for-agents","_rev":"5-70897062c3e61c2bea73f54c34aa9655","name":"@adhenawer-pkg/markdown-edge-for-agents","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@adhenawer-pkg/markdown-edge-for-agents","version":"0.1.0","license":"MIT","_id":"@adhenawer-pkg/markdown-edge-for-agents@0.1.0","maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"dist":{"shasum":"348b30f97a0a77dc0cf9d1cf6ba0c4425c3a3864","tarball":"https://registry.npmjs.org/@adhenawer-pkg/markdown-edge-for-agents/-/markdown-edge-for-agents-0.1.0.tgz","fileCount":4,"integrity":"sha512-iLxy14euWJbCYioHdplZLcyfBHuIqB9xn9FQqhsqPqqTTz8IDn120LyIxGBILWalQc60r77fxROFvdFfpP0B7w==","signatures":[{"sig":"MEYCIQC6PoSC1Inq4Mz+6lXcPx88NoVnLdEqQ+0MBGCs2Ok3TgIhAI2KyHGZ/oj6RsE2rIMY3blo3Jzwl8UyQi4qvJlF3ZbJ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47900},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"7384375352846f6f7d0ded699dc56f41436c8f36","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"adhenawer","email":"adhenawer@gmail.com"},"repository":{"url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git","type":"git"},"_npmVersion":"11.8.0","description":"Markdown for Agents, on any Edge. Free tier ready.","directories":{},"_nodeVersion":"25.6.0","dependencies":{"zod":"^3.23.0","markdown-for-agents":"^1.3.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.0","miniflare":"^4.0.0","typescript":"^5.5.0","html-rewriter-wasm":"^0.4.1","@vitest/coverage-v8":"^2.1.0","@cloudflare/workers-types":"^4.20250101.0"},"_npmOperationalInternal":{"tmp":"tmp/markdown-edge-for-agents_0.1.0_1776308631074_0.5399103677775419","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@adhenawer-pkg/markdown-edge-for-agents","version":"0.1.1","license":"MIT","_id":"@adhenawer-pkg/markdown-edge-for-agents@0.1.1","maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"dist":{"shasum":"3004f99db3366f8d309de47d77d803c327d50ec3","tarball":"https://registry.npmjs.org/@adhenawer-pkg/markdown-edge-for-agents/-/markdown-edge-for-agents-0.1.1.tgz","fileCount":5,"integrity":"sha512-4UQSTXpFJsymiVHCM7yN5YVtJ5BnfJA4fmtdr40TRG/jwad9WX+WPgxMqDHScWkwuY8865GnOXuvDOtyLA3ikg==","signatures":[{"sig":"MEUCIQDvY4t7rdqrDMhnXQWCFu5VdOWuqNNwLGCzRPA2IElljAIgL16l/wF/x4xaX+1h3OL6fhoPo4sdXgikOLJgjb+aiR4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52990},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"bf686e3c9c813542243eb35fb18cdae521a30a29","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"adhenawer","email":"adhenawer@gmail.com"},"repository":{"url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git","type":"git"},"_npmVersion":"11.8.0","description":"Markdown for Agents, on any Edge. Free tier ready.","directories":{},"_nodeVersion":"25.6.0","dependencies":{"zod":"^3.23.0","markdown-for-agents":"^1.3.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.0","miniflare":"^4.0.0","typescript":"^5.5.0","html-rewriter-wasm":"^0.4.1","@vitest/coverage-v8":"^2.1.0","@cloudflare/workers-types":"^4.20250101.0"},"_npmOperationalInternal":{"tmp":"tmp/markdown-edge-for-agents_0.1.1_1776309542153_0.7329960495155632","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@adhenawer-pkg/markdown-edge-for-agents","version":"0.1.2","license":"MIT","_id":"@adhenawer-pkg/markdown-edge-for-agents@0.1.2","maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"dist":{"shasum":"2d439391fca3f3a93c561445feeeb72f58aa09a8","tarball":"https://registry.npmjs.org/@adhenawer-pkg/markdown-edge-for-agents/-/markdown-edge-for-agents-0.1.2.tgz","fileCount":5,"integrity":"sha512-zmsG59/UreED0i4gm55ZxuFnwyh++ZT+4t9rzAhMG1+QabypGAXKzyyev8VK3uAsNPDUzmhcb/yZZSLHCmS69g==","signatures":[{"sig":"MEYCIQDn6UmyrtWLZac81ukwm74PCzQAmCai9WdAoiu8UO96rQIhALA5dyac8HPVoAFk31hRsYHXI/yOlX5tr9R62fn9g1op","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61884},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"d57480cc79d9a7d085dc3564dcb0d97bc6f97232","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"adhenawer","email":"adhenawer@gmail.com"},"repository":{"url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git","type":"git"},"_npmVersion":"11.8.0","description":"Markdown for Agents, on any Edge. Free tier ready.","directories":{},"_nodeVersion":"25.6.0","dependencies":{"zod":"^3.23.0","markdown-for-agents":"^1.3.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.0","miniflare":"^4.0.0","typescript":"^5.5.0","html-rewriter-wasm":"^0.4.1","@vitest/coverage-v8":"^2.1.0","@cloudflare/workers-types":"^4.20250101.0"},"_npmOperationalInternal":{"tmp":"tmp/markdown-edge-for-agents_0.1.2_1776310122194_0.17321033212619974","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@adhenawer-pkg/markdown-edge-for-agents","version":"0.2.0","license":"MIT","_id":"@adhenawer-pkg/markdown-edge-for-agents@0.2.0","maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"dist":{"shasum":"e5ecd4c4b29fe086a2cd7935984efff9435c073f","tarball":"https://registry.npmjs.org/@adhenawer-pkg/markdown-edge-for-agents/-/markdown-edge-for-agents-0.2.0.tgz","fileCount":5,"integrity":"sha512-ZJ+X7XjpxJ7Cs9MD2ekRVfYqPLIEUQhPgITLjXHcDD2aYuJCB+01SvlDkqdW8PioUhIjSP1wcUFkJGk9dlMrtg==","signatures":[{"sig":"MEQCIGlylqNwAagLSyKG8MSaEMhfN0xqGRAQvfeekWoeRdfRAiAOIhtAMkssOhe3gjxl77GlPrYBTKR8/i4OuOqGyxs81Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":66054},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"19ec52a5b66d9465f9a879e8e57dbd602c166f9b","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"adhenawer","email":"adhenawer@gmail.com"},"repository":{"url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git","type":"git"},"_npmVersion":"11.8.0","description":"Markdown for Agents, on any Edge. Free tier ready.","directories":{},"_nodeVersion":"25.6.0","dependencies":{"zod":"^3.23.0","markdown-for-agents":"^1.3.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.0","miniflare":"^4.0.0","typescript":"^5.5.0","html-rewriter-wasm":"^0.4.1","@vitest/coverage-v8":"^2.1.0","@cloudflare/workers-types":"^4.20250101.0"},"_npmOperationalInternal":{"tmp":"tmp/markdown-edge-for-agents_0.2.0_1776311268301_0.2587331665526751","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@adhenawer-pkg/markdown-edge-for-agents","version":"0.2.1","description":"Markdown for Agents, on any Edge. Free tier ready.","repository":{"type":"git","url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git"},"license":"MIT","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit"},"dependencies":{"markdown-for-agents":"^1.3.4","zod":"^3.23.0"},"devDependencies":{"@cloudflare/workers-types":"^4.20250101.0","@vitest/coverage-v8":"^2.1.0","html-rewriter-wasm":"^0.4.1","miniflare":"^4.0.0","tsup":"^8.3.0","typescript":"^5.5.0","vitest":"^2.1.0"},"publishConfig":{"access":"public"},"gitHead":"280dac47e1bf9d18380db9fd7b314cea1c6f7955","_id":"@adhenawer-pkg/markdown-edge-for-agents@0.2.1","bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-qOBZCfE7mEZVUZN2opW1/Sk2GmRGEe4gZXtKBi05C+cBQtyicreFKd6rBGV8W2kRTjkO4D3vq1L/X/Wqvzux8w==","shasum":"e4d4ed4e59a61511c8204fb83617fa3a817f5ba3","tarball":"https://registry.npmjs.org/@adhenawer-pkg/markdown-edge-for-agents/-/markdown-edge-for-agents-0.2.1.tgz","fileCount":5,"unpackedSize":67965,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCM1WrcURxjzqY2irA2Fahg45FpGNrLz8kV1zNJaU1dTwIhAObmQQjroL7bNAwMJ/GmWwy+hyxw7VdBsV4DdtMld6LC"}]},"_npmUser":{"name":"adhenawer","email":"adhenawer@gmail.com"},"directories":{},"maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/markdown-edge-for-agents_0.2.1_1776311651163_0.5829532208253119"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-16T03:03:50.990Z","modified":"2026-04-16T03:54:11.443Z","0.1.0":"2026-04-16T03:03:51.207Z","0.1.1":"2026-04-16T03:19:02.306Z","0.1.2":"2026-04-16T03:28:42.326Z","0.2.0":"2026-04-16T03:47:48.456Z","0.2.1":"2026-04-16T03:54:11.319Z"},"bugs":{"url":"https://github.com/adhenawer/markdown-edge-for-agents/issues"},"license":"MIT","homepage":"https://github.com/adhenawer/markdown-edge-for-agents#readme","repository":{"type":"git","url":"git+https://github.com/adhenawer/markdown-edge-for-agents.git"},"description":"Markdown for Agents, on any Edge. Free tier ready.","maintainers":[{"name":"adhenawer","email":"adhenawer@gmail.com"}],"readme":"# @adhenawer-pkg/markdown-edge-for-agents\n\n> Markdown for Agents, on any Edge. Free tier ready.\n\nDrop-in open-source alternative to Cloudflare's [Markdown for Agents](https://blog.cloudflare.com/markdown-for-agents/) feature (Pro+ only, $25/mo per zone). Serves markdown to AI agents via `Accept: text/markdown` content negotiation. 1:1 compatible with Cloudflare's official headers.\n\n[![CI](https://github.com/adhenawer/markdown-edge-for-agents/actions/workflows/ci.yml/badge.svg)](https://github.com/adhenawer/markdown-edge-for-agents/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/@adhenawer-pkg/markdown-edge-for-agents.svg)](https://npmjs.com/package/@adhenawer-pkg/markdown-edge-for-agents)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/adhenawer/markdown-edge-for-agents/blob/main/LICENSE)\n\n## Install\n\n```bash\nnpm install @adhenawer-pkg/markdown-edge-for-agents\n```\n\n## Usage\n\nCreate a Cloudflare Worker that serves markdown to AI agents:\n\n```ts\nimport { createMarkdownWorker } from \"@adhenawer-pkg/markdown-edge-for-agents\";\n\nexport default createMarkdownWorker({\n  preset: \"astro\",\n});\n```\n\nThat's it. When an AI agent requests your page with `Accept: text/markdown`, it gets clean markdown with YAML frontmatter. Browsers get the original HTML unchanged.\n\n### Custom config\n\n```ts\nexport default createMarkdownWorker({\n  preset: \"custom\",\n  selector: \"article\",\n  strip: [\".ad-banner\", \"nav\", \"footer\", \".cookie-notice\"],\n  frontmatter: [\"title\", \"author\", \"description\", \"lang\"],\n  redirects: {\n    \"/old-blog/*\": \"/posts/$1\",\n  },\n});\n```\n\n## How it works\n\n1. Agent sends `GET /post.html` with `Accept: text/markdown`\n2. Worker fetches original HTML from your origin\n3. HTML is converted to clean markdown (via [markdown-for-agents](https://github.com/kkonstantinov/markdown-for-agents))\n4. Metadata extracted from `<head>` becomes YAML frontmatter\n5. Response includes Cloudflare-compatible headers\n\n```\n$ curl -H \"Accept: text/markdown\" https://yoursite.com/post.html\n\n---\ntitle: \"My Post\"\nauthor: \"Jane\"\nsource: \"https://yoursite.com/post.html\"\nlang: en\n---\n\n# My Post\n\nContent here...\n```\n\n## Presets\n\nBuilt-in presets configure `selector` and `strip` for popular frameworks:\n\n| Preset | Selector | Strips |\n|---|---|---|\n| `astro` | `article`, `main[data-page-type='post']`, `main.content` | nav, header, footer, aside, script, style, [aria-hidden] |\n| `hugo` | `article`, `main .post-content`, `main.single` | nav, header.site-header, footer, .post-nav, .social-share |\n| `custom` | `article` | _(empty — you define)_ |\n\n## Config reference\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `preset` | `\"astro\" \\| \"hugo\" \\| \"custom\"` | **required** | Base config |\n| `selector` | `string` | from preset | CSS selector for content area |\n| `strip` | `string[]` | from preset | Elements to remove before converting |\n| `frontmatter` | `string[]` | `[\"title\",\"author\",\"description\",\"lang\"]` | YAML frontmatter fields |\n| `redirects` | `Record<string, string>` | `{}` | 301 redirects (run before negotiation) |\n| `forceMarkdownForUserAgents` | `RegExp[]` | `[]` | Force markdown for specific user agents |\n| `autoDetectAiCrawlers` | `boolean` | `false` | Auto-serve markdown to known AI bots (see below) |\n| `cache` | `{ maxAge, staleWhileRevalidate }` | `{ 3600, 86400 }` | Cache-Control values |\n| `debug` | `boolean` | `false` | Adds extra debug headers |\n\n## AI crawler auto-detection\n\nMost AI crawlers **don't send `Accept: text/markdown`** — they fetch your page as a browser would and parse the noisy HTML. Cloudflare's Pro feature only responds to that header, making it nearly useless in practice ([source](https://dri.es/markdown-llms-txt-and-ai-crawlers)).\n\nEnable `autoDetectAiCrawlers` to serve clean markdown automatically when a known AI bot visits:\n\n```ts\nexport default createMarkdownWorker({\n  preset: \"astro\",\n  autoDetectAiCrawlers: true,\n});\n```\n\n### Built-in crawler list (16 bots)\n\n| Provider | User-Agent patterns |\n|---|---|\n| OpenAI | `GPTBot`, `ChatGPT-User`, `OAI-SearchBot` |\n| Anthropic | `ClaudeBot`, `Claude-Web`, `anthropic-ai` |\n| Google | `Google-Extended`, `Googlebot-AI` |\n| Perplexity | `PerplexityBot` |\n| Apple | `Applebot-Extended` |\n| Cohere | `cohere-ai` |\n| Meta | `Meta-ExternalAgent`, `FacebookExternalHit` |\n| Amazon | `Amazonbot` |\n| Common Crawl | `CCBot` |\n| ByteDance | `Bytespider` |\n| Microsoft | `bingbot` |\n| You.com | `YouBot` |\n\nThe list is exported as `KNOWN_AI_CRAWLERS` for transparency:\n\n```ts\nimport { KNOWN_AI_CRAWLERS } from \"@adhenawer-pkg/markdown-edge-for-agents\";\nconsole.log(KNOWN_AI_CRAWLERS); // RegExp[]\n```\n\nYou can also combine auto-detection with custom patterns:\n\n```ts\nexport default createMarkdownWorker({\n  preset: \"custom\",\n  selector: \"article\",\n  autoDetectAiCrawlers: true,\n  forceMarkdownForUserAgents: [/MyInternalBot/i],\n});\n```\n\n### Comparison with Cloudflare Pro\n\n| Behavior | Cloudflare Pro | This lib |\n|---|---|---|\n| Responds to `Accept: text/markdown` | Yes | Yes |\n| Auto-serves markdown to AI crawlers by User-Agent | **No** | **Yes (16 bots)** |\n\nThis is a real differentiator: your content reaches AI systems in clean markdown even when they don't explicitly ask for it.\n\n## Response headers (1:1 Cloudflare compat)\n\n| Header | Value | Purpose |\n|---|---|---|\n| `Content-Type` | `text/markdown; charset=utf-8` | MIME type |\n| `x-markdown-tokens` | `6062` | Estimated token count |\n| `x-markdown-version` | `0.1.0` | Lib version |\n| `x-markdown-preset` | `astro` | Active preset |\n| `Content-Signal` | `ai-train=yes, search=yes, ai-input=yes` | AI opt-in signal |\n| `Vary` | `Accept` | Correct caching (HTML vs MD) |\n| `Cache-Control` | `public, max-age=3600, stale-while-revalidate=86400` | Configurable |\n\nThese match Cloudflare's native Pro feature, so migrating to Pro later is trivial — just flip the toggle and remove the worker.\n\n## Error handling\n\n- **Origin errors** (404, 5xx): passed through unchanged\n- **No article found** (selector didn't match): returns 404\n- **Conversion error**: falls back to original HTML with `x-markdown-error` header\n- **Non-HTML origin**: passed through unchanged\n- **Oversized content** (>10MB): returns 413\n\n## Quick start with scaffolder\n\nDon't want to set up manually? Use the companion CLI:\n\n```bash\nnpx create-markdown-edge-for-agents init\n```\n\nDetects your framework, generates the worker, installs deps, and deploys.\n\n## Requirements\n\n- Cloudflare Workers (Free tier works)\n- Node.js 22+ (for development)\n- wrangler 4+ (for deployment)\n\n## Roadmap\n\n- **v1.x**: Cloudflare Workers\n- **v2.x**: Multi-runtime (Vercel Edge, Deno Deploy, Bun, Node)\n- **Community**: more presets (Jekyll, 11ty, Next.js, Ghost)\n\n## Live demo\n\nThis lib powers [adhenawer.net](https://adhenawer.net):\n\n```bash\ncurl -H \"Accept: text/markdown\" https://adhenawer.net/posts/pt_br/fabio-akita-flow-588.html\n```\n\n## License\n\nMIT - [GitHub](https://github.com/adhenawer/markdown-edge-for-agents)\n","readmeFilename":"README.md"}