自定义技能

以 Markdown 格式查看

Fern Docs 站点可以提供您自己的 Agent 技能,供用户通过 skills CLI 发现和安装。您还可以在文档 UI 中添加”安装技能”按钮,点击后会打开一个包含安装命令和技能列表的弹窗。

1

组织文件结构

将技能放置在 fern/ 目录下的 .well-known/agent-skills/(当前 v0.2.0 规范)或 .well-known/skills/(旧版 v0.1.0 布局)中。两者都受支持且可以共存。每个技能是一个子目录,至少包含一个 SKILL.md,可选的支持文件放在旁边。

fern
docs.yml
.well-known
agent-skills
index.json# 发现清单(必需)
plant-care
SKILL.md# 技能说明
garden-planner
SKILL.md
references
api.md# 支持文件(可选)
2

编写每个 SKILL.md

每个 SKILL.md 需要包含 namedescription 的 YAML 前置数据,遵循 Agent Skills 规范

fern/.well-known/agent-skills/plant-care/SKILL.md
1---
2name: plant-care
3description: Guide for diagnosing and treating common plant diseases.
4---
5
6# Plant Care
7
8When diagnosing a plant issue, check for...
3

添加发现清单

技能目录根目录下的 index.json 是必需的。它列出所有技能,以便客户端可以通过单个请求发现它们,通过 urldigest 引用每个技能:

fern/.well-known/agent-skills/index.json
1{
2 "$schema": "https://schemas.agentskills.io/discovery/0.2.0/schema.json",
3 "skills": [
4 {
5 "name": "plant-care",
6 "type": "skill-md",
7 "description": "Guide for diagnosing and treating common plant diseases.",
8 "url": "/.well-known/agent-skills/plant-care/SKILL.md",
9 "digest": "sha256:c4d5e6f7..."
10 }
11 ]
12}

旧版 v0.1.0 清单为每个技能列出 files 数组,而非 urldigest

4

发布

Fern 在 fern generate --docs 期间上传文件包并按原样提供文件 — 无需 docs.yml 配置。fern check 在上传时验证文件包,标记以下问题:

  • 缺失或无法解析的 index.json
  • SKILL.mdname 不是 kebab-case、超过 64 个字符,或与其父目录名称不匹配
  • SKILL.md 缺少 descriptiondescription 为空(最多 1,024 个字符)

发布后,技能可通过以下地址访问:

  • https://your-docs-domain.com/.well-known/agent-skills/index.json(发现清单)
  • https://your-docs-domain.com/.well-known/agent-skills/<skill-name>/SKILL.md(单个技能)
  • https://your-docs-domain.com/.well-known/skills/index.json(旧版 v0.1.0 清单)

对于具有基础路径(如 /docs)的站点,端点位于该基础路径下(例如 https://example.com/docs/.well-known/agent-skills/index.json)。

5

安装技能

文件包发布后,任何人都可以通过以下命令安装您的技能:

$npx skills add https://your-docs-domain.com

https:// 协议前缀是必需的:裸域名会被视为 GitHub 仓库简写。

6

配置安装技能按钮

通过在页面操作栏中添加”安装技能”按钮来在文档 UI 中展示您的技能。在 docs.yml 中设置 page-actions.options.skills,按钮会打开一个弹窗,包含可复制的安装命令、可用技能列表以及可选的源仓库链接。

docs.yml
1page-actions:
2 options:
3 skills:
4 title: Plant API Skills
5 description: Skills for working with the Plant Store API.
6 repository: https://github.com/your-org/plant-api-skills
7 install-command: npx skills add https://your-docs-domain.com
8 skills:
9 - name: plant-care
10 description: Guide for diagnosing and treating common plant diseases.
11 url: https://github.com/your-org/plant-api-skills/tree/main/plant-care
12 - name: garden-planner
13 description: Plan garden layouts and planting schedules.

安装技能属性

docs.ymlpage-actions.options.skills 下配置安装技能按钮。

page-actions.options.skills
object

Enables the “Install skills” page action and configures the modal it opens. Omit to hide it.

page-actions.options.skills.title
string

Overrides the modal title.

page-actions.options.skills.description
string

Overrides the modal description.

page-actions.options.skills.learn-more-url
string

URL for a “Learn more” link shown alongside the description.

page-actions.options.skills.repository
string

Source repository URL displayed as a “View source” button in the modal.

page-actions.options.skills.install-command
string or list of strings

Command(s) shown as a copyable block in the modal. A single string is shown as-is; an array is joined with newlines for multi-step installs. Defaults to npx skills add https://<your-docs-domain> when omitted.

page-actions.options.skills.skills
list of objects

List of skills displayed in the modal. Each entry has a name (required), description (optional), and url (optional link to the skill source). When the site serves a /.well-known/agent-skills/index.json or /.well-known/skills/index.json manifest, the manifest replaces this list.