Skip to content

docs(plugins): align manifest schema doc with validators - #2019

Merged
vastsa merged 2 commits into
vastsa:mainfrom
zszz3:docs/plugin-manifest-schema-audit
Oct 31, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
zszz3:docs/plugin-manifest-schema-audit

Conversation

@zszz3

@zszz3 zszz3 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Related to #2000

P1 第 1 项:manifest schema 准确性审计。只改文档,中英文成对。

检查的文档

  • docs/spec/07-plugins/02-plugin-manifest-schema.md
  • docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md

对照的代码

  • SDK:PluginManifest、PLUGIN_PERMISSIONS、validateManifest()、validateContributions()(packages/plugin-sdk/src/index.ts)
  • 打包检查:pi-plugin check(packages/plugin-devkit/src/check.ts)
  • 宿主安装:read_manifest / validate_contributions(crates/host-core/src/plugins/manifest.rs、validation.rs)
  • 运行时:apps/desktop/electron/main/plugin-runtime.ts、apps/desktop/electron/main/ipc/plugin-ui-ipc.ts

发现与修改

# 文档原文 代码实际 修改
1 §5 权限枚举缺 5 项 PLUGIN_PERMISSIONS 还有 ui.settings、agent.extension、models.list、session.read、session.autoTitle(13 号权限矩阵也都有) 补齐,并指明权威来源是 PLUGIN_PERMISSIONS
2 §5 “Unknown permission = validation failure.”;§10 “unknown required permissions must fail” 只有 pi-plugin check 报 permission.unknown;validateManifest() 和 宿主 read_manifest 都不检查权限名 改为如实描述:check 报错、安装不拒绝、未知字符串不授予任何能力
3 §7 第 1 条 “schemaVersion must be 1”;§10 “host should reject a too-high major version” SDK 只做 typeof schemaVersion !== "number";宿主 schema_version: u32 仅反序列化,不比较取值 改为“必填且为数字,当前格式为 1,取值不校验”;§10 保留目标,补充现状
4 §7 第 2 条只列 id/name/version main 同样必填:SDK、宿主 “PLUGIN_INVALID: id/main required” 补上 main
5 §7 第 4 条 agentTools 需要 agent.tool.register(语气是校验失败) 只有 check.ts 报 permission.tools-missing;安装器 validate_contributions 不检查;运行时 agent.registerTool 才 assertPermission 写明三处各自的行为
6 §7 第 7 条 tool name “allows only” [a-zA-Z][a-zA-Z0-9_]* 无任何校验;运行时只要求 非空,pluginToolName 把其他字符替换为 _ 改为“应当”,并说明替换与可能的重名
7 §7 第 12 条“贡献→权限”列表不全 宿主还会拒绝:agentExtensions → agent.extension、windowAppearance → ui.window.appearance;scenicThemes 不在校验阶段检查,缺 ui.settings/ui.theme 时 IPC 直接跳过 补齐;zh 版同时补上英文版已有的 OAuth → provider.oauth
8 §4 PluginThemeContrib 无 variables SDK 有 variables?: PluginThemeVariableContrib[],文档开头 Appearance extensions 也在讲它 补字段
9 §4 PluginProviderContrib 无 description SDK 有 description?: string | PluginLocalizedString,§5.4 正文也在讲它 补字段

发现但未在本 PR 处理

  • §7 规则编号顺序是 15、17、16(英文版),属于 P0 的机械问题,不在本 PR 范围。
  • pi-plugin check 以“installer rejects package-relative assets (ADR 0255)”为由把包内相对路径的 theme asset 判为错误(check.ts),但宿主安装器实际接受包内相对路径(validation.rs,注释引用 ADR 0288),SDK 类型注释也说接受。这是代码问题,会另开 issue。

验证

  • git diff --check 通过
  • 本 PR 不新增、不改动标题和锚点;新增的 §5、§7 rule 1 交叉引用指向本文件现有章节
  • 分支基于 upstream/main 30f3c52

The manifest spec claimed checks that no validator performs and
omitted fields and permissions the SDK already ships. Authors reading
it would expect an unknown permission or a wrong schemaVersion to be
rejected at install, and could not find ui.settings, agent.extension,
models.list, session.read or session.autoTitle in the enum.

Correct the permission enum, the theme and provider contribution
types, and validation rules 1, 2, 4, 7 and 12 to match
validateManifest(), pi-plugin check and the host-core installer, in
both the English and zh-CN documents.

Related to vastsa#2000

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已独立对照 SDK 的 PluginManifest / PLUGIN_PERMISSIONS / validateManifest、DevKit check、Rust read_manifest / validate_contributions 及运行时工具命名和权限处理。文档新增的字段、45 项权限、未知权限、schemaVersion、agentTools 及 scenicThemes 的描述与当前实现一致;英文与中文对应,未发现阻塞问题。

在最新 main 4e1650b 上验证 GitHub 合并候选 c9f8306:diff --check、base ancestry、86 组中英配对、599 个文档页面、agent-policy sync 及 VitePress 生产构建通过。此 PR 只改文档,不需要应用 E2E。合入前同时确认 GitHub Docs checks 和 Head contains latest base 通过。

@vastsa
vastsa merged commit 9eb371e into vastsa:main Oct 31, 2026
2 checks passed
@Tioit-Wang

Copy link
Copy Markdown
Collaborator

Merged. Thanks!

This is the model for how #2000 asked audits to work: English and Chinese in the same PR, every finding tied to a code location, and the implementation bug split out to #2020 instead of being quietly patched into the docs. Both locales still align structurally (19 headings each) after your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants