Skip to content

Commit 9bf6f65

Browse files
authored
fix(infra): agent-friendly docs spec v0.5.0 — easy compliance wins (#182)
Closes two of the six failures found in #181. ## Summary - **`llms-txt-directive-md`**: inject `> For the complete documentation index, see [llms.txt](/llms.txt)` near the top of every generated `.md` file, inside `cleanMarkdown()` in `plugins/astro-agent-docs.mjs`. This is a new mandatory requirement in spec v0.5.0 (split from the previous single `llms-txt-directive` check). - **`content-negotiation`**: add `public/_headers` to serve `.md` files with `Content-Type: text/markdown; charset=utf-8`. Fixing this may also resolve the `content-start-position` failures (34/50 pages) as a side effect — once agents receive a proper `text/markdown` response, they should use the clean `.md` files (which start with content immediately) instead of converting Starlight's nav-heavy HTML. ## Sync recommendation hand-written
1 parent c6a13f4 commit 9bf6f65

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

plugins/astro-agent-docs.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ const SECTIONS = deriveSections(sidebar);
8787
// a charset=utf-8 in the Content-Type header.
8888
const BOM = "\uFEFF";
8989

90+
const LLMS_TXT_DIRECTIVE =
91+
"> For the complete documentation index, see [llms.txt](/llms.txt)\n\n";
92+
9093
/** Strip YAML frontmatter, HTML comments, and MDX artifacts; prepend title heading. */
9194
function cleanMarkdown(raw, isMdx = false) {
9295
const { data, content } = matter(raw);
@@ -96,7 +99,7 @@ function cleanMarkdown(raw, isMdx = false) {
9699
}
97100
body = body.replace(/\n{3,}/g, "\n\n").trim();
98101
const title = data.title ? `# ${data.title}\n\n` : "";
99-
return BOM + title + body + "\n";
102+
return BOM + title + LLMS_TXT_DIRECTIVE + body + "\n";
100103
}
101104

102105
/**

public/_headers

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*.md
2+
Content-Type: text/markdown; charset=utf-8

0 commit comments

Comments
 (0)