# @agentmarkup/core 中文文档

规范地址：https://npmcn.com/package/%40agentmarkup/core/

版本：0\.7\.0
npm 元数据更新时间：2026-08-23T17:47:25.541Z
中文译文更新时间：2026-11-06T21:56:30.868Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40agentmarkup/core
原文对照：https://npmcn.com/package/%40agentmarkup/core/?lang=original
项目主页：https://agentmarkup.dev/
源码仓库：https://github.com/agentmarkup/agentmarkup

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：129 kB，9 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-03-20T14:36:44.778Z
- 最新版本发布：2026-08-23T17:47:25.349Z
- 近 30 天下载量：2291（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：14（近 12 个月 14 个）

## 中文简介

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

## 安装

```sh
npm install @agentmarkup/core
```

也可以使用：`pnpm add @agentmarkup/core`、`yarn add @agentmarkup/core`、`bun add @agentmarkup/core`

## README

# @ agentmarkup/ 核心

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

## 安装

```bash
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`,并且没有"漏镜"验证警告.

```ts
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 [塞巴斯蒂安·科奇内斯库](https://www.cochinescu.com/)麻省理工学院执照.

用于生产 [阿尼玛·费利克斯](https://animafelix.com/)。 。 。 .

## 许可证

麻省理工学院.

## 常见问题

### @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 和提交记录判断。

