@afps-spec/schema

中文文档
0.12.0发布于 2026/10/19Apache-2.0ES Module构建来源已验证近 30 天下载 5587

Zod schemas and generated JSON Schema 2020-12 definitions for AFPS 0.3 manifests (agent, skill, mcp-server, integration).

原始使用文档
文档目录6 节
  1. npm package
  2. JSON Schema generation
  3. Versioned schemas
  4. Schema validation
  5. Regenerating
  6. Usage in manifests

AFPS JSON Schemas

Machine-readable representation of the AFPS specification. The specification text (spec.md) is the normative source.

npm package

This directory is published as @afps-spec/schema on npm. Implementations can import the Zod schemas and extend them:

import { agentManifestSchema } from "@afps-spec/schema";

const myAgentSchema = agentManifestSchema.extend({
  // Extensions go under `_meta`, keyed by a reverse-DNS namespace (spec §10).
  _meta: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
});

JSON Schema generation

When generating JSON Schema files from AFPS Zod schemas, use the exported afpsJsonSchemaOverride to ensure the input.schema and output.schema fields reference the official JSON Schema 2020-12 meta-schema:

import { toJSONSchema } from "zod/v4/core";
import { agentManifestSchema, afpsJsonSchemaOverride } from "@afps-spec/schema";

const jsonSchema = toJSONSchema(agentManifestSchema, {
  target: "draft-2020-12",
  override: afpsJsonSchemaOverride,
});

Without the override, these fields serialize as opaque {} objects because the AJV meta-schema validation cannot be represented by Zod's toJSONSchema() alone.

Versioned schemas

Schemas are organized by major version:

schema/
├── v0/                   ← AFPS v0.x schemas
│   ├── agent.schema.json
│   ├── skill.schema.json
│   ├── mcp-server.schema.json
│   └── integration.schema.json
├── src/
│   ├── schemas.ts        ← Zod source (generates v0/)
│   ├── generate.ts       ← Generation script
│   └── index.ts          ← npm entry point
└── package.json          ← @afps-spec/schema

URLs follow the pattern https://schemas.afps.dev/v0/<type>.schema.json.

The mcp-server.schema.json validates the MCP Bundle (MCPB) manifest a built mcp-server package embeds; AFPS-specific data is carried under the MCPB _meta object.

Schema validation

AFPS schema fields (input.schema, output.schema) accept any valid JSON Schema 2020-12 document, with two AFPS-specific constraints:

  • The root type MUST be "object"
  • The root MUST have a properties key

Runtime validation is performed by AJV against the official JSON Schema 2020-12 meta-schema. The generated .schema.json files express this via allOf combining a $ref to the meta-schema with the AFPS constraints.

Regenerating

After modifying the Zod source in src/schemas.ts:

cd schema && bun install && bun run generate

Usage in manifests

Reference a schema using $schema for editor validation:

{
  "$schema": "https://schemas.afps.dev/v0/agent.schema.json",
  "schema_version": "0.3",
  "name": "@scope/my-agent",
  "version": "1.0.0",
  "type": "agent"
}

Implementations may extend these schemas with additional fields under the _meta reverse-DNS namespace convention (see spec §10).

版本与发布记录

@afps-spec/schema 共发布 27 个版本,首次发布于 2026/03/16;过去 12 个月发布了 27 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.12.0latest2026/10/1919 天前
0.11.02026/10/1920 天前
0.10.02026/10/1820 天前
0.9.02026/10/0930 天前
0.8.02026/10/0830 天前
0.7.02026/08/282 个月前

关于 @afps-spec/schema 的常见问题

@afps-spec/schema 是什么?

Zod schemas and generated JSON Schema 2020-12 definitions for AFPS 0.3 manifests (agent, skill, mcp-server, integration).

如何安装 @afps-spec/schema?

在项目目录运行 npm install @afps-spec/schema,或使用 pnpm add / yarn add / bun add。

@afps-spec/schema 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/afps-spec__schema 是否存在。

@afps-spec/schema 支持 ESM 还是 CommonJS?

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

@afps-spec/schema 可以商用吗?

@afps-spec/schema 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@afps-spec/schema 的下载量有多少?

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

@afps-spec/schema 还在维护吗?

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