openclaw

关注公众号 jb51net

关闭
AI > openclaw >

OpenClaw .NET兼容性目录指南(CompatibilityCatalog)

张善友

概述

compat/public-smoke.json 是 OpenClaw.NET 兼容性验证体系的核心清单文件。它承担着以下关键职责:

无论是发布前的回归验证、外部集成方的兼容性自查,还是社区贡献者新增插件,都以该清单为唯一事实来源(Single Source of Truth)。

文件结构

清单顶层是一个带版本号的 JSON 对象,entries 字段为条目数组:

{
  "version": 2,
  "entries": [
    {
      "id": "agentseo-plugin",
      "category": "ts-jiti-plugin",
      "kind": "npm-plugin",
      "spec": "@agentseo/openclaw-plugin@0.1.4",
      "packageName": "@agentseo/openclaw-plugin",
      "pluginId": "agentseo",
      "expectedStatus": "compatible",
      "configJson": "{\"apiKey\":\"test_key\"}",
      "expectedToolNames": ["agentseo_audit", "agentseo_keywords"],
      "expectedSkillNames": ["agentseo"]
    }
  ]
}

条目字段说明

字段按用途分为三组:通用字段技能专用字段插件专用字段

通用字段(所有条目必填)

字段类型说明
idstring场景唯一标识,须在 entries 中保持唯一
categorystring场景分类:pure-skilljs-tool-plugints-jiti-pluginconfig-schema-pluginunsupported-surface-plugin
kindstring资源类型:clawhub-skill 或 npm-plugin

技能专用字段(kind == "clawhub-skill"

字段类型必填说明
slugstringClawHub 中的技能标识符
versionstring技能的 SemVer 版本
expectedRelativePathstring安装后的预期相对路径,如 skills/my-skill/SKILL.md

插件专用字段(kind == "npm-plugin"

字段类型必填说明
specstringNPM 包规范,如 @agentseo/openclaw-plugin@0.1.4
packageNamestringNPM 包名
pluginIdstring插件唯一标识
expectedStatusstring预期兼容性状态:compatible 或 incompatible
configJsonstring⭕️JSON 字符串形式的示例配置
installExtraPackagesstring[]⭕️需要额外安装的依赖包列表
expectedToolNamesstring[]⭕️预期暴露的工具名称(仅 compatible 场景)
expectedSkillNamesstring[]⭕️预期提供的技能名称(仅 compatible 场景)
expectedDiagnosticCodesstring[]⭕️预期的诊断错误码(仅 incompatible 场景)

⚠️ 注意:NPM 插件条目必须显式指定 expectedStatus,编译期校验会拒绝缺失该字段的条目。

场景分类详解

OpenClaw.NET 共定义了 5 种 category,覆盖了从纯技能到负面用例的全部典型场景:

Category说明测试目的典型示例
pure-skill独立技能包,无 NPM 依赖验证 SKILL.md 格式与 ClawHub 安装流程pdf-form-filler
js-tool-pluginJavaScript 编写的桥接插件验证 JS 插件加载与工具导出@example/js-plugin
ts-jiti-pluginTypeScript + JITI 转译的插件验证 TypeScript 转译与 JITI 集成@agentseo/openclaw-plugin
config-schema-plugin配置校验负面场景验证无效配置被检测并返回诊断码缺失必填字段 / 字段类型错误
unsupported-surface-plugin不支持功能的负面场景验证不支持的 API 被显式拒绝注册 CLI 命令 / 调用受限 API

正面与负面场景

正面场景(expectedStatus = "compatible"

负面场景(expectedStatus = "incompatible"

诊断码含义
config_one_of_mismatch配置不满足 oneOf 约束
unsupported_cli_registration插件尝试注册不支持的 CLI 命令
unsupported_surface_call调用了未公开/受限的 API 表面
schema_required_missing必填字段缺失

使用方式

CLI 查询

OpenClaw CLI 提供 compatibility catalog 子命令,便于本地查询与脚本消费:

# 查看所有条目
openclaw compatibility catalog
# 按状态过滤
openclaw compatibility catalog --status compatible
openclaw compatibility catalog --status incompatible
# 按类型与分类过滤
openclaw compatibility catalog --kind npm-plugin --category ts-jiti-plugin
# JSON 格式输出(适用于程序化消费)
openclaw compatibility catalog --json
# 简写形式
openclaw compat catalog

REST API

Gateway 通过 /api/integration/compatibility 路由族对外暴露:

GET /api/integration/compatibility/catalog
GET /api/integration/compatibility/catalog?compatibilityStatus=compatible
GET /api/integration/compatibility/catalog?kind=npm-plugin&category=ts-jiti-plugin
GET /api/integration/compatibility/export

自动化测试

测试类 PublicCompatibilitySmokeTests 在运行时自动读取清单并迭代执行:

CI/CD 集成

在 GitHub Actions 中,public-compatibility-smoke 作业承担清单的回归验证:

如何贡献新条目

添加新技能

{
  "id": "my-new-skill",
  "category": "pure-skill",
  "kind": "clawhub-skill",
  "slug": "my-new-skill",
  "version": "1.0.0",
  "expectedRelativePath": "skills/my-new-skill/SKILL.md"
}

添加兼容插件(正面场景)

{
  "id": "my-plugin",
  "category": "js-tool-plugin",
  "kind": "npm-plugin",
  "spec": "@my-org/openclaw-plugin@1.0.0",
  "packageName": "@my-org/openclaw-plugin",
  "pluginId": "my-plugin",
  "expectedStatus": "compatible",
  "configJson": "{\"apiKey\":\"test_key\"}",
  "expectedToolNames": ["my_tool_1", "my_tool_2"],
  "expectedSkillNames": ["my-skill"]
}

添加不兼容场景(负面场景)

{
  "id": "broken-plugin-example",
  "category": "config-schema-plugin",
  "kind": "npm-plugin",
  "spec": "@my-org/broken-plugin@1.0.0",
  "packageName": "@my-org/broken-plugin",
  "pluginId": "broken-plugin",
  "expectedStatus": "incompatible",
  "configJson": "{\"wrongField\": 123}",
  "expectedDiagnosticCodes": ["config_one_of_mismatch"]
}

贡献流程

dotnet test OpenClaw.Net.slnx --filter Category=PublicSmoke

数据转换逻辑

清单在运行时通过 PublicCompatibilityCatalog.CreateCatalog() 转换为富目录(Rich Catalog),以便 CLI 与 REST API 直接消费。核心映射规则如下:

源字段生成字段转换逻辑
slug / packageName / pluginId / idSubject按优先级取第一个非空值
kind + spec / slugInstallCommand技能:openclaw clawhub install {slug}插件:openclaw plugins install {spec} --dry-run
category + expectedStatusSummary根据场景性质生成人类可读描述
expectedStatusScenarioTypecompatible → "positive"incompatible → "negative"
多字段组合Guidance[]上下文相关的操作建议(如"配置 schema 错误,请参考插件文档")

与 NativeAOT 的关系

OpenClaw.NET 的 NativeAOT 约束直接影响清单的加载与序列化方式:

故障排查

症状可能原因解决方案
测试报告 "plugin failed to load"configJson 格式错误或字段类型不匹配检查 JSON 是否符合插件实际 schema,使用 --dry-run 先行验证
"expected tool not found"插件未声明该工具或工具名拼写错误校对 expectedToolNames 与插件运行时实际暴露的工具名
编译期错误 "npm-plugin must declare expectedStatus"新条目缺少 expectedStatus 字段明确指定 "compatible" 或 "incompatible"
烟雾测试整体未运行环境变量未设置设置 OPENCLAW_PUBLIC_SMOKE=1 后重试
clawhub 安装失败Node.js 未安装或版本过低安装 Node.js 20+ 并确保 npx 可用
expectedDiagnosticCodes 不匹配错误码命名变更或新增查阅最新诊断码列表,必要时同步更新清单
AOT 模式启动报缺少元数据新增字段未在 CoreJsonContext 中声明在源生成上下文中添加对应类型

到此这篇关于OpenClaw.NET 兼容性目录指南(Compatibility Catalog)的文章就介绍到这了,更多相关OpenClaw.NET 兼容性内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!