AI 专区For AI
「AI 友好」不是文档写得多,而是让模型一次做对、改完不漂移——契约喂给类型、文档与工具三端,永远不会互相打架。“AI-friendly” is not about more docs — it is about getting it right the first time, with no drift. One contract feeds types, docs and tools alike.
为什么它适合 AI 用Why AI works well with it
- 契约即真相:模型拿到的 props / class 契约来自源码本身,不是过期的文档。Contracts as truth: the props and class contracts models receive are extracted from the source — never stale docs.
- 真实令牌值:
get_tokens返回运行用的色值,模型不需要、也不应该凭记忆写#1890ff。Real token values:get_tokensreturns the actual colors — models need not (and should not) guess#1890ff. - 铁律可执行:7 条 lint 规则把交互铁律变成 exit code,写完就能自动核。Executable rules: seven lint rules turn behavior rules into exit codes — verify right after writing.
MCP 工具MCP tools4
启动 mcp/server.mjs 后,AI 可通过四个工具拿准确数据(零依赖,手写 JSON-RPC)。Run mcp/server.mjs and AI gets accurate data through four tools (zero-dependency, hand-written JSON-RPC).
list_components列出 AuthNexus Design 的全部组件与逻辑模块。返回 name / 中文名 / 分组 / 一句话说明。写新代码前先调用它,避免用错组件名或自造 class。
group— 按分组过滤keyword— 按名称/说明里的关键词模糊匹配(中文或英文均可)
get_component取单个组件的完整契约:props(类型/必填/默认值)、emits、slots、class 契约、依赖、a11y 约定。**用 class 时照抄 classes.asset 列表**,不要自己拼——那是本设计系统唯一的命名空间(anx-)。
name必填required — 组件名,如 SelectMenu / TablePager
get_tokens取设计令牌的**真实计算值**(颜色/圆角/间距/玻璃/动效/布局/字体)。写样式时用它取色值——不要凭记忆写 #1890ff 之类。brand.css 里的是可覆盖的品牌层。
group— 只取某一组;不传则全给name— 只要某个具体令牌,如 --acid
search_patterns取已验证的组合范式(登录表单 / 表格分页 / 抽屉表单 / 确认弹窗 / 空状态 / 操作反馈)。遇到「这类页面怎么搭」的问题先查这里——范式里的铁律都是踩过坑总结的。
need— 需求描述关键词,如 登录 / 分页 / 抽屉
{
"mcpServers": {
"authnexus-design": {
"command": "node",
"args": ["/path/to/authnexus-design/mcp/server.mjs"]
}
}
}lint 规则Lint rules7
| ID | 级别Level | 规则Rule | 为什么Why |
|---|---|---|---|
no-native-select |
error | 禁止原生 <select>:弹出层由系统绘制,圆角/动效/玻璃全部失效 | assets 的 .anx-select 只有盒样式;assets 的 SelectMenu 才是可定制的下拉 |
overlay-must-wrap |
error | 浮层(.anx-modal / .anx-drawer / .anx-scrim)必须包在 .anx-overlay-layer 内 | 浮层自身没有 z-index,承载层才提供 100 层;缺了会被顶栏(30)/侧栏(40) 反压 |
toast-need-icon |
error | toast 必须包含 .anx-toast__icon,否则三种 tone 看起来一样 | tone 的视觉区分完全在图标颜色上(ok 绿 / danger 红 / info 墨) |
class-need-anx |
error | 资产 class 漏了 anx- 前缀 | 命名空间隔离:与宿主框架/全局样式撞名会互相污染(见 ADOPT.md §5) |
no-raw-color |
warn | 样式里出现裸色值,应改用设计令牌 | 令牌是明暗双主题与品牌覆盖的唯一入口;写死色值会在深色主题下错色 |
no-paged-transform |
error | 分页滑动要加在整块容器上并用 .anx-paged-clip 裁剪,不能只给 tbody 加 transform | 只给 tbody 加 transform 会撑出横向滚动条(BEHAVIOR §4 实测教训) |
no-od-leak |
warn | od-* 是 OpenDesign 第三方层,不应出现在新代码里 | 它是原型遗留层;新代码应只用 anx- 资产类 |
单一数据源管线One source, many outputs
契约从源码提取,四类生成物由它派生——改组件后重跑两个命令,全链路一致。Contracts are extracted from source; four artifacts derive from them. Re-run two commands after a change and the whole chain stays consistent.
contracts/components/*.json ← 唯一数据源(从源码提取,33 份)
│
├─→ dist/vue.d.ts 组件类型(props / emits / slots)
├─→ dist/index.d.ts 逻辑模块签名(从源码提取)
├─→ contracts/generated/api.md 官网与本页的 API 表
└─→ mcp/server.mjs 的工具描述 AI 拿到的准确契约python tools/extract-contracts.py # 源码 → 契约
node tools/gen-types.mjs # 契约 → 类型 + API 文档
node mcp/server.mjs --selftest # 契约 → MCP 工具(自检 4 项断言)