wp-abilities-verify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWP Abilities Verify
WP Abilities Verify
Verify a WordPress plugin's Abilities API registrations. The
centerpiece is the adversarial annotation correctness check: a
ability that actually writes (via ,
, a non-GET delegate, etc.) is a security and UX
disaster because agents plan actions on the basis of the annotations
they introspect. This skill catches those lies by reading the callback
body and comparing what it does against what the annotation claims.
readonly: true$wpdb->updateupdate_optionThe skill also validates audit docs produced by ,
checks permission gates and schema hygiene, and optionally executes
each ability against a live environment.
wp-abilities-audit验证WordPress插件的Abilities API注册情况。核心功能是对抗性注解正确性检查:标注为但实际执行写入操作(如通过、、非GET委托等)的能力会引发安全和用户体验问题,因为智能体(Agent)会基于其自省到的注解来规划操作。本工具通过读取回调函数体,将实际行为与注解声明进行对比,从而识别此类不符情况。
readonly: true$wpdb->updateupdate_option本工具还可验证生成的审计文档、检查权限网关与架构规范性,并可选择性地在真实环境中执行每个能力。
wp-abilities-auditWhen to use
使用场景
- After abilities have been registered in a plugin but before a PR lands.
- As a health-check on an already-shipped plugin (catch regressions where a refactor turned a readonly ability into a writing one).
- To validate an audit document before handing it to an implementer.
- 插件中注册能力后、PR合并前。
- 作为已发布插件的健康检查工具(捕捉重构导致只读能力变为写入能力的回归问题)。
- 向开发者交付前验证审计文档。
Two modes
两种模式
- Static mode — runs from the plugin checkout. No env. Enumerates via source inspection, runs the adversarial correctness check, runs schema and permission lints, and validates audit docs.
- Runtime mode — requires a running env. Does everything static
does PLUS: for authoritative enumeration, executes each ability with curated inputs, confirms permission roundtrip against real users, and runs a twin-invocation heuristic on
wp_get_abilities()abilities to flag candidates for review (return-value equality is a signal, not a verdict — core defines idempotent as "no additional effect on the environment").idempotent: true
Both modes produce the same structured report format.
A static-mode PASS means "no obvious-shape violations," not "verified
write-free." For high-stakes plugins, run runtime mode before landing
— it catches bootstrap-order, permission-roundtrip, and idempotency
issues that static can't. See
for the static blind spots.
references/annotation-correctness.md- 静态模式 — 基于插件代码仓库运行,无需环境。通过源码检查枚举能力、执行对抗性正确性检查、运行架构与权限校验、验证审计文档。
- 运行时模式 — 需要运行中的环境。包含静态模式的所有功能,额外增加:通过获取权威的能力枚举结果、使用预设输入执行每个能力、针对真实用户验证权限往返逻辑、对标注
wp_get_abilities()的能力执行双调用启发式检查以标记需复核的候选(返回值相等是参考信号而非最终结论——核心定义中幂等指“对环境无额外影响”)。idempotent: true
两种模式都会生成相同结构的报告格式。
静态模式通过仅代表“无明显格式违规”,而非“已验证无写入操作”。对于高风险插件,合并前应运行运行时模式——它能捕捉静态模式无法检测的启动顺序、权限往返和幂等性问题。详见中的静态模式盲区说明。
references/annotation-correctness.mdInputs required
所需输入
- Plugin checkout path — working tree to verify.
- Mode — or
static. Default to static if unspecified.runtime - (Runtime only) Env-up command — read the plugin's . Common patterns:
AGENTS.md,npm run wp-env start, or a composer-based bring-up. Plugin families with their own dev tooling will document their own command. Do NOT assumenpx wp-env startworks.npm run wp-env - (Optional) Audit doc path — enables cross-checks between the audit and the registered abilities, and validates the audit itself.
- Report output path — explicit path, typically the user's vault.
- 插件代码仓库路径 — 待验证的工作目录。
- 模式 — 或
static。未指定时默认使用静态模式。runtime - (仅运行时模式)环境启动命令 — 查看插件的文档。常见命令如:
AGENTS.md、npm run wp-env start或基于Composer的启动命令。拥有自研开发工具的插件家族会在文档中说明专属命令,请勿默认使用npx wp-env start。npm run wp-env - (可选)审计文档路径 — 启用审计文档与已注册能力的交叉校验,并验证审计文档本身。
- 报告输出路径 — 明确的输出路径,通常为用户的存储目录。
Prerequisites
前置条件
- has been run on the plugin.
wp-project-triage - The plugin has at least one registered ability in source. Zero hits
on → return a clear "no abilities registered" report, not an empty PASS.
wp_register_ability(
- 已对插件运行。
wp-project-triage - 插件源码中至少注册了一个能力。若未找到调用,需返回清晰的“未注册任何能力”报告,而非空的通过结果。
wp_register_ability(
Procedure
执行流程
1. (If audit provided) Validate the audit doc
1.(若提供审计文档)验证审计文档
Read . Validate the audit
against the canonical schema owned by . Surface
missing required fields, multiple , and
entries that aren't paired with a
entry. alone is WARN (intentional gap output), not
FAIL.
references/audit-schema-validation.mdwp-abilities-auditreference_ability: truebacking: nullsurfaced_gapsbacking: null阅读。对照的标准架构验证审计文档,指出缺失的必填字段、多个的情况,以及未搭配项的条目。仅属于警告(故意留空的输出),而非失败。
references/audit-schema-validation.mdwp-abilities-auditreference_ability: truesurfaced_gapsbacking: nullbacking: null2. Enumerate abilities statically
2. 静态枚举能力
Read . Find each
call, extract the name, the annotation block,
and the execute-callback location. Use a multi-line tool () — the canonical formatting splits the call
across lines. Record each ability's source-file + line + annotations +
callback byte range.
references/static-enumeration.mdwp_register_ability(rg --multiline --pcre2阅读。查找每个调用,提取名称、注解块和执行回调的位置。使用多行工具(如)——标准格式会将调用拆分为多行。记录每个能力的源文件+行号+注解+回调字节范围。
references/static-enumeration.mdwp_register_ability(rg --multiline --pcre23. (Runtime only) Enumerate via REST + wp-cli
3.(仅运行时模式)通过REST与wp-cli枚举
Read . Bring the env up using the
command from , then enumerate via over
wp-cli and cross-check against the static inventory. Source-only →
FAIL (registration not firing). Runtime-only → WARN (dynamic
registration path).
references/runtime-harness.mdAGENTS.mdwp_get_abilities()阅读。使用中的命令启动环境,然后通过wp-cli调用枚举能力,并与静态枚举结果交叉校验。仅存在于源码中的能力→失败(未触发注册)。仅存在于运行时的能力→警告(动态注册路径)。
references/runtime-harness.mdAGENTS.mdwp_get_abilities()4. Annotation correctness (the adversarial core)
4. 注解正确性(对抗性核心)
Read . Read each callback body
and verify it matches the annotation claim:
references/annotation-correctness.md- → callback must not write to the database, the options table, post / user / term / comment data, the filesystem, cron, or via non-GET HTTP / REST delegates.
readonly: true - → callback must not delete, refund, void, cancel, or trash.
destructive: false - → repeated calls with the same input have no additional effect on the environment (per the
idempotent: trueannotation's docblock inidempotent). Static catches counter writes and per-call cron schedules; runtime adds a twin-invocation heuristic for visible state changes.class-wp-ability.php
The reference lists common write patterns as a starting set, not a
checklist — plugin vocabularies vary, and the agent extends with verbs
specific to the plugin under verification.
False positives get suppressed via an inline comment.
// verify-ignore: <annotation> -- <reason>阅读。读取每个回调函数体,验证其是否符合注解声明:
references/annotation-correctness.md- → 回调不得写入数据库、选项表、文章/用户/分类/评论数据、文件系统、定时任务,或通过非GET HTTP/REST委托执行写入。
readonly: true - → 回调不得执行删除、退款、作废、取消或移入回收站操作。
destructive: false - → 使用相同输入重复调用对环境无额外影响(符合
idempotent: true中class-wp-ability.php注解的文档块定义)。静态模式会捕捉计数器写入和每次调用创建的定时任务;运行时模式增加双调用启发式检查以识别可见状态变化。idempotent
参考文档列出了常见写入模式作为基础检查项,而非完整清单——插件词汇各不相同,工具会针对当前验证的插件扩展专属动词。
误报可通过行内注释抑制。
// verify-ignore: <annotation> -- <reason>5. Permission roundtrip
5. 权限往返校验
Read . Static: classify each
against the six shapes (preferred Shape A
; FAIL on Shape B-bad
patterns or Shape E literal ). Runtime: anon and subscriber
denied; admin allowed (unless deliberately public). When an audit was
provided, cross-check the registered cap against the audit's declared
gate.
references/permission-roundtrip.mdpermission_callbackcurrent_user_can(...)WP_REST_Requesttrue阅读。静态模式:将每个归类为六种类型(推荐使用类型A;若使用类型B的错误模式或类型E的字面量则判定为失败)。运行时模式:匿名用户和订阅者被拒绝;管理员被允许(除非刻意设置为公开)。若提供了审计文档,需将已注册的权限与审计文档中声明的网关进行交叉校验。
references/permission-roundtrip.mdpermission_callbackcurrent_user_can(...)WP_REST_Requesttrue6. Schema lints
6. 架构校验
Read . Six small principles applied to
each ability's : object schemas declare
; required fields have descriptions; enums
non-empty; no ; defaults are statically constant (including
); reference abilities have no required inputs.
references/schema-lints.mdinput_schemaadditionalProperties$ref(object) array()Cross-reference
for the four runtime gotchas (defaults not injected on the
property-level path, pagination key drift, on string IDs,
direct vs indirect invocation strictness).
../wp-abilities-api/references/input-schema-gotchas.mdempty()阅读。对每个能力的应用六项原则:对象架构需声明;必填字段需包含描述;枚举值非空;无引用;默认值为静态常量(包括);引用能力无必填输入。
references/schema-lints.mdinput_schemaadditionalProperties$ref(object) array()对照中的四个运行时陷阱(属性级路径未注入默认值、分页键偏移、字符串ID使用、直接与间接调用的严格性差异)。
../wp-abilities-api/references/input-schema-gotchas.mdempty()7. Error-code vocabulary
7. 错误码词汇校验
Cross-reference .
Inspect each callback's returns; non-vocabulary codes →
WARN.
../wp-abilities-api/references/error-code-vocabulary.mdWP_Error对照。检查每个回调返回的;非标准词汇的错误码→警告。
../wp-abilities-api/references/error-code-vocabulary.mdWP_ErrorVerification
验证报告
The run produces a structured markdown report at the user-specified
path:
---
Last updated: <YYYY-MM-DD HH:MM>
---运行后会在用户指定路径生成结构化Markdown报告:
---
Last updated: <YYYY-MM-DD HH:MM>
---<Plugin> Abilities Verification — <Static|Runtime> Mode
<插件名称> Abilities 验证报告 — <静态|运行时>模式
Status: <PASS|WARN|FAIL>
状态: <通过|警告|失败>
Audit doc validation (if provided)
审计文档验证(若提供)
Static inventory
静态能力清单
Annotation correctness
注解正确性
| Ability | Claim | Result | Evidence |
|---|
| 能力 | 声明 | 结果 | 证据 |
|---|
Permission gates
权限网关
Schema lints
架构校验
Error-code vocabulary
错误码词汇
Every ability is OK, WARN, or FAIL. A single FAIL → top-line FAIL;
WARNs without FAILs → WARN; otherwise PASS.
每个能力的状态为通过、警告或失败。存在单个失败→整体状态失败;仅存在警告无失败→整体状态警告;否则为通过。Failure modes / debugging
失败模式/调试
- Env not reachable (runtime) — env-up failed or Docker isn't
running. Re-run , then fix the env. Don't fall back silently to static without noting it in the report.
wp-project-triage - No abilities in source — return a clear "nothing to verify" report.
- Audit schema mismatch — point at
; don't auto-fix the audit.
references/audit-schema-validation.md - False positive on readonly-writes — see the mechanism in
// verify-ignore. Document why each suppression is legitimate.references/annotation-correctness.md - Runtime enumeration smaller than static — registration hook isn't firing. Check init hook timing, activation state, autoloader order.
- 环境无法访问(运行时模式) — 环境启动失败或Docker未运行。重新运行,然后修复环境。请勿静默切换为静态模式,需在报告中注明。
wp-project-triage - 源码中无能力 — 返回清晰的“无内容可验证”报告。
- 审计架构不匹配 — 指向;请勿自动修复审计文档。
references/audit-schema-validation.md - 只读写入的误报 — 参考中的
references/annotation-correctness.md机制。记录每个抑制操作的合理原因。// verify-ignore - 运行时枚举结果少于静态枚举 — 注册钩子未触发。检查初始化钩子时机、激活状态、自动加载顺序。
Escalation
升级流程
- Recurring legitimate pattern that trips the adversarial check across
multiple plugins → propose adding it to the suppression guidance in
. Don't broaden the candidate-pattern list speculatively.
annotation-correctness.md - Audit-schema validator rejects a legitimate audit → the canonical
schema in has evolved. Update
../wp-abilities-audit/references/audit-schema.mdto match.references/audit-schema-validation.md
- 多个插件中反复出现触发对抗性检查的合理模式→建议将其添加到的抑制指南中。请勿随意扩展候选模式列表。
annotation-correctness.md - 审计架构验证器拒绝合理的审计文档→中的标准架构已更新。需将
../wp-abilities-audit/references/audit-schema.md更新为匹配版本。references/audit-schema-validation.md
Out of scope
超出范围
Token-budget measurement is a separate verification axis — an
annotation-clean, schema-clean, runtime-passing ability set can still
be unshippable if its form burns through an agent's
context budget. That axis is tracked separately. Do not aggregate
manual or external measurement into this skill's PASS / FAIL verdict.
tools/list令牌预算测量属于独立的验证维度——注解合规、架构合规、运行时通过的能力集仍可能因形式消耗过多智能体上下文预算而无法发布。该维度需单独跟踪,请勿将手动或外部测量结果纳入本工具的通过/失败结论。
tools/list