@agentmarkup/core

中文文档
0.7.0发布于 2026/08/24MITTypeScriptES Module零依赖近 30 天下载 2291

框架-不可知的 llms.txt, llms- full.txt, A2A 代理卡, JSON- LD, markdown 镜像, 头像, AI 爬行控制器, 以及验证

中文使用文档
文档目录5 节
  1. 安装
  2. 使用量
  3. 内容包括
  4. 维护者
  5. 许可证

@ agentmarkup/ 核心

框架不可知性 llms.txt选项 llms-full.txt,可选 A2A 代理卡,JSON-LD,标记下镜,AI 爬行器 robots.txt,标题,以及机器可读网站的验证原始.

安装

pnpm add -D @agentmarkup/core

使用量

@agentmarkup/core 用于适配器作者和已经拥有自定义的先发或后发管道的站点.

软件包家族还包括Vite、Astro和Next.js的专用适配器,因为这些框架拥有足够的最终建设产出.

帮助者是友好共存的: patchRobotsTxt() 匹配手动爬行器规则的叶子没有被修改过,在核心上建造的适配器可以保存所保存的 llms.txt 默认情况下,文件或现有的JSON-LD.

llmsTxt.whenToUse 需要一份简短、具体的声明清单,其中说明网站应该从事的工作。 它们是作为标有标记的子弹清单在自由式细节块中提供的 llms.txt 财务报告和审定财务报表 llms-full.txt在第一个之前 ## 因此,代理阅读列表 学习何时到达网站 而不是猜测 从营销副本.

何时 markdownPages.enabled 开始, generateLlmsTxt() 默认情况下, 更喜欢同一站点的标记下镜像 URL 用于页面条目, 所以代理先发现清除路径 。 这通常在生的HTML薄或吵时最有用. 设定 llmsTxt.preferMarkdownMirrors: false 将 HTML URL 保留在 llms.txt。 。 。 .

markdownPages.exclude 使用不应获得镜像的页面路径,匹配方式与 pages[].path。用于已存在但不包含内容的页面 404 页面是常见的情况,因为镜像发布一个URL,用"找不到"的文本回答200个,并用"cononicalise"回答404s的URL. 被排除在外的页面总是在任何地方跳过:否 .md 文件,没有 text/markdown 交替链接, 无条形 Link 头部,没有标记下 URL llms.txt,并且没有"漏镜"验证警告.

import {
  generateAgentCard,
  generateContentSignalHeaders,
  generateLlmsTxt,
  generateMarkdownCanonicalHeaders,
  generatePageMarkdown,
  generateJsonLdTags,
  patchRobotsTxt,
  presetToJsonLd,
  validateAgentCardConfig,
  validateAgentCardJson,
  validateExistingJsonLd,
  validateLlmsTxt,
  validateRobotsTxt,
} from '@agentmarkup/core';

const builtHtml = '<html><head><title>Pricing</title></head><body><main><h1>Pricing</h1><p>Plans and billing.</p></main></body></html>';

const llms = generateLlmsTxt({
  site: 'https://example.com',
  name: 'Example',
  description: 'Machine-readable metadata for an example site.',
  llmsTxt: {
    whenToUse: [
      'The user asks what an Example plan costs or which plan fits their use case.',
      'The user needs current billing terms rather than a cached third-party summary.',
    ],
    sections: [
      {
        title: 'Public pages',
        entries: [{ title: 'Pricing', url: '/pricing', description: 'Plans and billing' }],
      },
    ],
  },
});

const agentCard = generateAgentCard({
  site: 'https://example.com',
  name: 'Example',
  description: 'Machine-readable metadata for an example site.',
  agentCard: {
    version: '1.0.0',
    supportedInterfaces: [
      {
        url: 'https://agent.example.com/a2a/v1',
        protocolBinding: 'HTTP+JSON',
        protocolVersion: '1.0',
      },
    ],
    skills: [],
  },
});

const jsonLd = generateJsonLdTags([
  presetToJsonLd({ preset: 'webSite', name: 'Example', url: 'https://example.com' }),
]);

const robots = patchRobotsTxt(existingRobotsTxt, {
  GPTBot: 'allow',
  ClaudeBot: 'allow',
});

const markdown = generatePageMarkdown({
  html: builtHtml,
  pagePath: '/pricing/',
  siteUrl: 'https://example.com',
});

const headers = generateContentSignalHeaders({
  aiTrain: 'yes',
  search: 'yes',
  aiInput: 'yes',
});

const markdownCanonicalHeaders = generateMarkdownCanonicalHeaders([
  {
    markdownPath: '/pricing.md',
    canonicalUrl: 'https://example.com/pricing',
  },
]);

const llmsIssues = validateLlmsTxt(llms ?? '');
const robotsIssues = validateRobotsTxt(robots, {
  GPTBot: 'allow',
  ClaudeBot: 'allow',
});
const agentCardIssues = agentCard ? validateAgentCardJson(agentCard) : [];
const schemaIssues = validateExistingJsonLd(builtHtml, '/pricing/');

何时 agentCard 启用,提供 version,至少一个 supportedInterfaces 条目,并通过顶层进行非空描述 description 或者说 agentCard.description启用 validateAgentCardConfig() 如果你想在一代人之前飞过这个配置.

内容包括

  • llms.txt 发电机和验证器
  • 选项 llms-full.txt 发电机
  • 可选 A2A 代理卡生成器加配置和 JSON 验证器
  • llms.txt 发现链接生成
  • JSON- LD 序列化和 HTML 注入辅助器
  • 现有的JSON-LD检查和验证
  • HTML 薄壳验证
  • markdown 页面生成工具,用于更清洁的代理获取路径
  • 标记下反向链接和镜像覆盖验证
  • schema.org 预设构建器
  • 人工智能爬行器 robots.txt 生成和补丁
  • Content-Signal 政策的生成和补丁 robots.txt (动画)和 _headers 标题
  • 犬类 Link 标记下镜像头生成
  • 确定性计划和爬行者验证

维护者

版权(c)2026 塞巴斯蒂安·科奇内斯库麻省理工学院执照.

用于生产 阿尼玛·费利克斯。 。 。 .

许可证

麻省理工学院.

版本与发布记录

@agentmarkup/core 共发布 14 个版本,首次发布于 2026/03/20;过去 12 个月发布了 14 个版本。

版本发布日期距今
0.7.0latest2026/08/242 个月前
0.6.02026/08/232 个月前
0.5.52026/07/074 个月前
0.5.42026/07/074 个月前
0.5.32026/07/024 个月前
0.5.22026/07/024 个月前

关于 @agentmarkup/core 的常见问题

@agentmarkup/core 是什么?

框架-不可知的 llms.txt, llms- full.txt, A2A 代理卡, JSON- LD, markdown 镜像, 头像, AI 爬行控制器, 以及验证

如何安装 @agentmarkup/core?

在项目目录运行 npm install @agentmarkup/core,或使用 pnpm add / yarn add / bun add。

@agentmarkup/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentmarkup/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agentmarkup/core 可以商用吗?

@agentmarkup/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentmarkup/core 的下载量有多少?

根据 npm 官方下载统计,@agentmarkup/core 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,291 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentmarkup/core 还在维护吗?

最新版本 0.7.0 发布于 2026/08/24(2 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2026/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。