插件示例
报告模板与 Agent 技能两类声明式插件的完整示例清单。
仓库 docs/plugins/examples/ 提供两个声明式插件示例:它们不包含计算代码,只用清单声明内容,由宿主按规则使用。计算方法插件的完整写法可以参照仓库 plugins/ 中的第一方插件,例如 plugins/cablesim.gb50217-correction/。下面的文件内容在构建时直接读取自仓库,与仓库保持一致。
报告模板(report-template)
能力 kind 为 report-template:声明计算书的章节、可引用的数据和版面模板。报告模板不能混入方法输出,也不能触发计算。
{
"schema": "cablesim.plugin/2",
"id": "example.report-template",
"version": "1.0.0",
"name": "结果与来源报告模板",
"description": "未发布的声明示例,供审阅插件规范。",
"icon": "assets/icon.svg",
"publisher": {
"id": "example",
"name": "规范示例"
},
"host_api": {
"major": 2,
"min_minor": 1
},
"license": {
"spdx": "CC0-1.0",
"review_required": false
},
"platforms": [
"windows-x64",
"linux-x64"
],
"permissions": [],
"dependencies": [],
"resources": {
"timeout_s": 8,
"memory_mb": 64,
"network": "none"
},
"capabilities": [
{
"kind": "report-template",
"id": "results-report",
"title": "结果与来源报告模板",
"description": "仅供规范审阅的未发布声明示例。",
"method_version": "1.0.0",
"analysis": "declaration",
"input_schema": "cablesim.report-context/1",
"outputs": [],
"artifacts": [],
"validation": {
"level": "unverified",
"cases": []
},
"limitations": [
"仅定义声明,不启用运行时,不代表工程批准。"
],
"category": "report",
"report_template": {
"context_schema": "cablesim.report-context/1",
"format": "html",
"entry": "assets/template.html",
"sections": [
{
"id": "results",
"title": "工程结果",
"source": "results",
"required": true
},
{
"id": "provenance",
"title": "来源与局限",
"source": "provenance",
"required": true
}
],
"engineering_approval": false
}
}
],
"files": [
{
"path": "assets/icon.svg",
"sha256": "9f24fcde59dc7d46d0e08077c0f2cd571a2b4d6fab99b6f35445ea7d027bca04",
"size_bytes": 147
},
{
"path": "assets/template.html",
"sha256": "11253cca44c748dffb361949c2e5755b25ba5eaa89b93411ae14a8d72f7713ca",
"size_bytes": 242
}
]
}
<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>结果与来源</title><h1>结果与来源</h1><p>声明示例;尚无模板运行时。结果、来源与局限由已核验上下文绑定,不在模板中计算。</p></html>
Agent 技能(agent-skill)
能力 kind 为 agent-skill:声明一个 Agent 可以执行的多步任务,每一步引用宿主或其他插件已有的能力及输入绑定。技能只编排已有能力,不能放宽权限、跳过预检或代替人工批准。
{
"schema": "cablesim.plugin/2",
"id": "example.agent-skill",
"version": "1.0.0",
"name": "型号电气核验技能",
"description": "未发布的声明示例,供审阅插件规范。",
"icon": "assets/icon.svg",
"publisher": {
"id": "example",
"name": "规范示例"
},
"host_api": {
"major": 2,
"min_minor": 1
},
"license": {
"spdx": "CC0-1.0",
"review_required": false
},
"platforms": [
"windows-x64",
"linux-x64"
],
"permissions": [],
"dependencies": [],
"resources": {
"timeout_s": 8,
"memory_mb": 64,
"network": "none"
},
"capabilities": [
{
"kind": "agent-skill",
"id": "type-check",
"title": "型号电气核验技能",
"description": "仅供规范审阅的未发布声明示例。",
"method_version": "1.0.0",
"analysis": "declaration",
"input_schema": "cablesim.workflow-context/1",
"outputs": [],
"artifacts": [],
"validation": {
"level": "unverified",
"cases": []
},
"limitations": [
"仅定义声明,不启用运行时,不代表工程批准。"
],
"category": "agent-skill",
"agent_skill": {
"context_schema": "cablesim.workflow-context/1",
"effects": [
"read",
"calculate",
"propose"
],
"engineering_approval": false,
"human_approval_required_for": [
"workspace.change",
"engineering.accept",
"external.send"
],
"steps": [
{
"id": "electrical",
"title": "核验所选型号电气参数",
"capability": {
"plugin_id": "cablesim.type-electrical",
"capability": "electrical",
"version": "1.0.0"
},
"parameters_template": {},
"bindings": [
{
"target": "/parameters/cable_type_id",
"source": "/inputs/selected_cable_type_id"
},
{
"target": "/input",
"source": "/inputs/domain"
}
]
}
]
}
}
],
"files": [
{
"path": "assets/icon.svg",
"sha256": "9f24fcde59dc7d46d0e08077c0f2cd571a2b4d6fab99b6f35445ea7d027bca04",
"size_bytes": 147
}
]
}
开发与验证
- 在
plugins/<id>/下放置plugin.json、源码和资源; - 用
python scripts/plugin_sdk.py seal plugins/<id>/plugin.json --write生成封签; - 用
python scripts/plugin_sdk.py verify校验; - 在
tests/或插件自带的测试中,用独立的解析解、手算或公开算例核对结果,并把用例写进清单的validation。
字段说明见插件清单字段。