mcpField
S
Standards by Applied Form

Standards by Applied Form

本地服务
github.com开发工具01 周前更新

关于 Standards by Applied Form

Standards 是面向网页团队的设计系统一致性检查工具,可在 Chromium 中检查页面的实际渲染结果。它会在多个宽度和显示模式下验证页面,并报告或修复规则违规。

主要功能

  1. 01按设计令牌检查渲染样式
  2. 02测试多种宽度、减少动态效果和打印模式
  3. 03检查无障碍和页面规则
  4. 04生成基线和 HTML 审计报告
  5. 05应用可处理的页面修复

适用场景

  1. 01检查页面是否符合设计系统
  2. 02审计页面目录并查看结果
  3. 03根据已保存基线跟踪违规
  4. 04发布前应用可用修复

MCP 相关

Standards 提供 MCP 服务,包含用于检查和修复页面的 `standards_lint` 与 `standards_fix` 工具。MCP 调用仅检查调用方指定的宽度。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"applied-form-standards": {
"command": "npx",
"args": [
"-y",
"@appliedform/standards"
]
}
}
}
启动命令npx -y @appliedform/standards

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@appliedform/standards4.0.1

工具

9

收录的工具列表 · 更新于 1 周前

参数类型必填说明
urlstring否用于检查的 file:// 或 https:// 页面。
htmlstring否要检查的完整 HTML 文档。
registerenum否如果文档未声明页面所属的 register,则指定该 register。i | ii
viewportsarray否要检查的宽度。默认为系统的四个宽度,以及从其间抽样的两个宽度。

详细介绍

按应用表单制定的标准

在真实浏览器中衡量设计系统的符合性门禁。提供一个 DTCG 令牌文件和一个页面;它会在 Chromium 中以四种固定宽度和另外两种采样宽度渲染页面,并在减少动态效果和打印模式下检查每个计算值是否符合系统规则。它报告的是浏览器实际绘制的内容,而不是样式表中的声明。

Standards 是开源的,因此任何人都可以核查相关证据。在本仓库中,可以重新运行它参与的每项比较:与 axe-core 和 stylelint 并列的门禁、对公开设计系统的偏差调查,以及模型研究和各轮评审(包括用于评分的每条记录)。

开始

npm install @appliedform/standards && npx playwright install chromium
npx standards init --pack instrument  # load a system: the free Standards pack, or your pack's tokens.json
npx standards lint page.html          # your page, judged by that system's rules, at every width

未加载系统时,standards lint 会依据适用于任何页面的规则(对比度、焦点、目标尺寸、溢出、替代文本、标题顺序、动态效果)评判页面,并说明如何加载系统。对于 Agent,npx standards mcp-config 会输出适用于 Claude Code 或 Cursor 的服务配置块。

使用

npx standards lint page.html https://example.com/page      # every rule, every width
npx standards lint https://example.com/ --register ii      # a page that has not declared a register
npx standards baseline https://example.com/a --out standards-baseline.json
npx standards lint https://example.com/a --baseline standards-baseline.json
npx standards fix page.html                                # apply the fixes it can make; writes page.fixed.html
npx standards audit pages/ --fix                           # every page in a folder, as found and as the fixer would leave it, as one report
npx standards drift https://example.com/ --out drift.json  # what system a site actually renders
npx standards rules                                        # every rule, its severity and what it checks
npx standards mcp                                          # the same tools for a model, over MCP

standards fix 在修复后的页面通过所有已检查规则时以 0 退出码退出;仍有违规时以 1 退出,并按规则和元素列出无法修复的问题。standards audit 会生成一个自包含的 HTML 页面(以及 --json),其中包含按规则和页面分类的检查结果、相关规则涉及的 WCAG 标准、未检查的内容,以及用于重复运行检查的命令。standards lint 遇到任何未列入基线的错误级违规时以 1 退出。standards.config.json 可将规则设为 error、warn 或 off;standards.config.example.json 是一个起始模板。例外是强制规则:令牌文件中 $extensions["form.applied"].levels.mandatory 下列出的 contrast、text-too-small、target-size、focus-hidden、link-not-underlined、alt-missing、horizontal-overflow 和 wordmark-live-text。如果配置将其中任何一项设为 warn 或 off,系统会拒绝该配置,且 standards lint 以 2 退出(Applied Form 仓库中的决策 0027)。通过令牌文件加载的系统可以提高阈值 contrast 和 text-too-small 所读取的值(floors.body-contrast、display-contrast、large-text-px、large-bold-text-px、text-min-px),但如果将其中任何一项降低到令牌文件自身值以下,系统会拒绝该配置。声明了 pack、却未声明 register.pack 的系统也会被拒绝:它先仅依据 register 评判每个页面,随后又舍弃了这条设计系统规则,因此没有测量任何强制规则。背景不是颜色的 register 所属系统也会被拒绝。目前已知有四处缺口。在已加载系统未定义 register 的页面上,无论是否加载系统,降低 register 的配置都会导致强制规则无法测量。声明自身为 pack 的系统文件在评判时不会检查 text-too-small、link-not-underlined 和 wordmark-live-text。对于没有绘制底色的页面,contrast 会依据系统指定的底色进行测量。MCP 工具 standards_lint 和 standards_fix 只会测量调用方指定的宽度,因此未包含 320 的调用不会在 320px 下测量 horizontal-overflow。

名称变更

在 3.x 中,产品名为 engine,命令为 af。这些旧名称在 4.x 中仍可使用,每次使用时都会在 stderr 输出一行弃用提示,并将在 Standards 5.0.0 中移除。安装 @appliedform/standards 前,请先卸载 @appliedform/engine:两者都包含 af 和 af-mcp 可执行文件,因此将其中一个全局安装到另一个之上会因 EEXIST 而失败。

3.x现在旧名称的处理方式
软件包 @appliedform/engine@appliedform/standards请先卸载 @appliedform/engine
命令 afstandards在 stderr 输出一行提示后,运行相同的命令
af-mcp、af mcpstandards mcp与之前一样提供服务,并列出 af_* 工具
工具 af_lint 和另外八个工具standards_lint 和另外八个工具每个路由都接受这两种名称
af.config.jsonstandards.config.json读取时输出一行提示;如果两个文件都存在,则优先使用新文件
af-baseline.jsonstandards-baseline.json在其原路径读取和写入,并输出一行提示
.af/.standards/配置中的路径仍是普通路径,继续有效
AF_BRAND、AF_CHROMIUMSTANDARDS_SYSTEM、STANDARDS_CHROMIUM每次使用时读取,并输出一行提示;如果一对变量都设置为不同的值,则以状态码 2 退出
af-audit.html,默认报告文件standards-audit.html无
engine 可执行文件无无

重命名之前记录的文档,例如决策记录、评估协议及其结果,仍使用旧名称,不会改写。

令牌文件

tokens/applied-form.tokens.json 是参考系统:它包含 Standards 的结构(registers、voices、spacing、floors 和每条规则的参数),以及由 standards brand 生成的中性配色方案。该文件用于测试和发布 Standards,并非可直接交付的设计。替换此文件,或使用 standards system import 导入 Standards 包,即可将其指向你自己的系统。

证据

内容位置重新运行
与 axe-core 和 stylelint 对比,在植入缺陷上的门控效果eval/compare.mjs、test/compare.test.mjsnpm run eval:compare
不同公开设计系统之间的偏差eval/drift/npm run drift:batch -- all
使用和不使用规则生成页面的模型eval/、docs/evaluation-protocol.md离线运行 npm run eval -- --models stub,然后使用密钥运行
包含锚点和注意力检查的评判轮次eval/judge-run.mjsnpm run eval:judge

该协议在其规范的运行开始前编写,并说明了什么样的结果会对 Standards 不利。这些运行都基于此仓库的克隆版本:npm 软件包包含 Standards,但不包含任何需要模型 SDK、axe-core 或 stylelint 的内容。

开发

npm install
npm run check    # build, unit tests, and the clean fixture linted in a real browser

测试使用 node:test。如果 Playwright 尚未下载 Chromium,请将 STANDARDS_CHROMIUM 设置为 Chromium 可执行文件的路径。

许可证

Apache-2.0。请参阅 LICENSE 和 NOTICE。名称 Applied Form 及其标记不在许可范围内。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。