关闭

Tryaivo™技术

组件文档拆成.md喂给llms.txt,agent不再瞎编props

2026-12-05 00:19:26 浏览:

导语: 把设计系统文档从"HTML 页面"改成"组件级 .md 双胞胎 + llms.txt 索引",代理才能读到正确的 token 名与 props 签名;我们实测了 12 个公开设计系统的 llms.txt 端点,5 个正常、1 个"200 但返回 HTML"、2 个直接拒绝。

背景:设计系统文档是 agent 最容易读错的一类页面

前端/设计系统文档站的典型结构是:组件页依赖 JS 渲染、props 表格藏在可折叠面板里、token 名散落在样式示例中。人类读起来没问题,但代理抓下来往往是一堆导航与代码高亮的碎片,于是出现三类典型错误:

  • token 名瞎编:把 color.background.primary 写成 bg-primary、PrimaryBackground 等不存在的名字;

  • props 幻觉:给了组件不存在的 variant(例如给只有 solid/faded/outline/ghost 的按钮编一个 primary);

  • 拿旧版本写码:v3 组件已经废弃,代理还在按 v2 的属性写。

Supernova 在 2026 年 10 月 5–6 日对 31 个公开设计系统做了 AI 就绪度审计(共 310 个潜在得分点),结论是文档代理可读性(llms.txt 项)是全场最低的一块:62 个可得分点里丢了 53 个,31 个站里 25 个压根没有可用的 llms.txt,只有 3 个站算"通过"。同期 Ahrefs 的 13.7 万域名日志研究给出另一组数据:97% 的 llms.txt 文件没有被抓取过——文件写了不等于被读,这一点后面踩坑部分再说。

落地清单:三个文件怎么分工

Supernova 给的划分是我目前看到最清晰的一套,直接决定文件放在哪个域、给谁读:

文件放哪给谁读内容
robots.txt / sitemap.xml文档根爬虫 + 传统搜索页面级发现与抓取许可
llms.txt / llms-full.txt文档根(仅 Docs 域根,不要每层一份)代理与文档爬虫组件/Token 的 Markdown 索引 + 全文
AGENTS.md你的产品仓库根IDE 里的编码代理本地规则,指回 llms.txt 或 MCP 端点

1)llms.txt:只做索引,链接一律指向 .md

可抄的模板(Supernova 公开版本,已脱敏为 Acme 示例):

# Acme Design System

> Token, component, and accessibility documentation for @acme/ui (v4.2). Read these Markdown specs before writing UI code, and never guess token names or component props.

## Foundations and Agent Rules- [Agent Coding Contract](https://ds.acme.com/docs/agent-rules.md): Required package imports, semantic-token-only policy, and banned legacy components
- [Accessibility Baseline](https://ds.acme.com/docs/accessibility.md): Keyboard navigation, focus ring contrast, and required ARIA attributes

## Design Tokens
- [Semantic Color Tokens](https://ds.acme.com/docs/tokens/color.md): Background, foreground, and border tokens across light and dark modes
- [Spacing and Typography](https://ds.acme.com/docs/tokens/scale.md): Scale tokens and responsive type ramp rules

## Components
- [Button](https://ds.acme.com/docs/components/button.md): Variants, sizes, loading state, icon props, and label rules
- [Modal](https://ds.acme.com/docs/components/modal.md): Focus trapping, confirm patterns, and destructive action rules
- [Form Field](https://ds.acme.com/docs/components/form-field.md): Label association, helper text, and inline validation states

## Patterns and Deprecations
- [Form Composition](https://ds.acme.com/docs/patterns/forms.md): Layout spacing, submit placement, and error summary behavior
- [Deprecated API Map](https://ds.acme.com/docs/deprecations.md): Legacy v3 components and props mapped directly to v4 replacements

## Optional
- [v3 to v4 Migration Guide](https://ds.acme.com/docs/migration-v4.md): Codemods and breaking prop renames
- [Full Bundle (Small Context Only)](https://ds.acme.com/llms-full.txt): Combined Markdown export for offline or single-shot prompts

三条硬要求:H1 只有一行 # 产品名、紧跟一行 > 摘要句(写明"不要猜 token 名/不要猜 props"这类护栏)、所有链接指 .md 而不是 HTML 路由。最后一段 ## Optional 单独放迁移指南与全量包,是 llmstxt.org 的约定,用来暗示"这一段可以不读",能显著降低代理把 2MB 全文直接塞进上下文的概率。

2)真实站点的四种写法(都可以直接抄结构)

我于 2026-12-05 用 HTTP 实测了这些端点,长度与状态都是当场取的:

站点端点实测手法
Ant Design/llms.txt200,text/plain,34,788 字符索引里同时挂 llms-full.txt、llms-full-cn.txt、llms-semantic.md、design.md;组件级 .md 可单独取(/components/button.md 200,37,599 字符 text/markdown)
React Spectrum/llms.txt200,17,500 字符索引里写相对路径 Accordion.md,解析到站点根,/Accordion.md 200、10,509 字符 text/markdown
USWDS/llms.txt200,17,331 字符护栏式:明确声明"HTML 标记不可妥协",禁止用框架包装组件
Chakra UI/llms.txt200,1,085 字符主题分割索引:只放目录,正文分到 llms-components.txt / llms-theming.txt(89,799 字符)/ llms-charts.txt / llms-v3-migration.txt
Atlassian Design System/llms.txt200,5,781 字符轻量索引

Chakra 的分片索引原文就这么短,值得照抄——索引越短,代理越可能顺着链接往下读:

# Chakra UI v3 Documentation for LLMs

## Documentation Sets
- [Complete documentation](https://chakra-ui.com/llms-full.txt)
- [Components](https://chakra-ui.com/llms-components.txt)
- [Charts](https://chakra-ui.com/llms-charts.txt)
- [Styling](https://chakra-ui.com/llms-styling.txt)
- [Theming](https://chakra-ui.com/llms-theming.txt)
- [Migrating to v3](https://chakra-ui.com/llms-v3-migration.txt)

3)llms-full.txt:要"薄",或者干脆不给

Ant Design 的 llms-full.txt 实测 2,149,942 字符(约 2.1MB),Chakra 的 llms-full.txt 2,230,646 字符。这个体量任何代理都不会整篇塞进上下文——它们会截断,而截断点通常决定代理读到哪个版本。所以要么像 Ant Design 这样在索引里明确标注"Full Bundle (Small Context Only)",要么像 Cloudflare 那样让 llms-full 只给搜索 API 指令而非全量 dump(我们此前复盘过),要么干脆只做分片。

4)robots 与 MCP 的配合项

  • robots.txt 里单独具名放行文档爬虫(GPTBot / ClaudeBot / OAI-SearchBot / PerplexityBot),不要只靠通配组;

  • 静态 Markdown 的天花板很清楚:它说不清"当前主题下 Primary 到底是哪个色值"这类需要实时解析的问题。Supernova 在 2026-11-23 的 live 测试里,用它的 MCP 端点 /mcp 一次调用就把 Background/Primary 解析成 #104FC6,并返回 Button 全部 34 个 typed props(variant: solid/faded/outline/ghost)。结论:索引层用 llms.txt,精确取值层上 MCP,别指望一个静态文件解决全部。

结果:文件写了,代理真的读了吗

先给有出处的数据,再给我们的现场复核。

指标数值口径
31 个设计系统中缺可用 llms.txt25 个Supernova 2026-10-05/06 审计,公开研究,非第三方复现
审计中"通过"的站3 个同上
llms.txt 项失分62 分丢 53 分(85.5%)同上
llms.txt 被抓取比例仅 3% 被读(97% 未抓取)Ahrefs 13.7 万域名日志研究,经 Supernova 引用

我们的现场复核(2026-12-05,Mozilla/5.0 UA,逐一 HTTP 请求 12 个公开设计系统,只看状态码与 Content-Type):

结果站点
200 + text/plain(真文件)Ant Design(34,788) / React Spectrum(17,500) / USWDS(17,331) / Chakra(1,085) / Atlassian(5,781)
200 但 Content-Type 是 text/html(340,956 字符的 SPA 页面)Polaris(Shopify)/llms.txt
403 拒绝design.gitlab.com
404m3.material.io

这组结果说明两件事:

  1. 头部项目确实落地了,而且不是随便写个清单,是组件级 .md 双胞胎(Ant 的 button.md 37,599 字符、React Spectrum 的 Accordion.md 10,509 字符),这才是代理能读对 props 的前提;

  2. "200 就是成功"是假象。Polaris 的端点返回 200,但给的是 340KB 的 HTML 单页应用外壳——代理拿到的全是导航与脚本,等于没写。这个坑与 Signals Corps 2026-10 的扫描结论一致:在 113,457 个返回 llms.txt 响应的站点里,62,751 个给出真文件,36% 返回的其实是 HTML 页面。

定性观察(没有第三方复现数据,不编数字):把组件页从 HTML 换成 .md 双胞胎之后,代理最常犯的错从"编造 token 名与 variant"退化为"找不到某个页面"——前者是错答案,后者只是缺答案,用户侧体感差别很大。

复盘:3 条可以直接抄的配置动作

  1. llms.txt 只做索引,链接全部指 .md,且每个链接带一句 60 字内的说明(写清"变体/尺寸/状态/无障碍规则"这类关键信息点),代理靠这句决定读不读。

  2. 组件级 .md 双胞胎必须能单独取到:/components/button.md 返回 text/markdown,内容是完整 props 表 + 示例,而不是"请看 HTML 页面"。

  3. 索引分片,全文慎给:主索引 ≤ 1.5 万字符,全文按主题拆(theming / components / charts / migration),全量包标注"仅小上下文场景"。

两条踩坑提醒

  1. 别把 llms-full 当卖点:2.1MB / 2.23MB 的 llms-full.txt 实测存在,但代理会截断,截断点落在哪个版本你无法控制。要么瘦身,要么只给搜索 API 指令。

  2. 上线后必须验 Content-Type:200 且 text/html(如 Polaris 的 340KB 页面)是典型假成功;验收命令应为 curl -sI https://site/llms.txt | grep -i content-type,必须出现 text/plain 或 text/markdown,且首行为 # 。

标注

  • llms.txt 版本:v2(llmstxt.org,2026-08)

  • 规范状态:作者主张 / 社区约定,未被 LLM 厂商官方确认为抓取标准

  • 主要来源:Supernova《llms.txt for Design Systems: Data, Template, and MCP Limits》(审计 2026-10-05/06,MCP live 测试 2026-11-23);Ahrefs llms.txt 研究(经其引用);Signals Corps 2026-10 扫描(经 Clauday 2026-10-17 报道)

  • 现场复核时间:2026-12-05,本机 HTTP 实测 12 个设计系统端点 + 5 个 .md 双胞胎

  • 数据口径:Supernova 与 Ahrefs 均为研究方自述,非第三方复现;文中所有长度、状态码为本机当日实测

标签:llms.txt、AI可见度、AIWO、结构化暴露、前端设计系统