本页目录
domain.yaml
一个领域插件就是一份 YAML 文件。它声明你领域的标签、轴、contract 脚手架,以及 L5 校验器。
运行时从 $PRIME_DIR 递归发现它,不用改代码。
最小例子
# domain.yaml — at the corpus root
name: my-domain
version: "1.0.0"
description: One sentence describing what knowledge lives in this corpus. 这就是合法的最小 domain。运行时会加载它;标签和校验器都是可选的。
完整参考
name: frontend-design
version: "1.0.0"
description: Design knowledge for AI agents — color, typography, motion, spacing,
accessibility, and component patterns.
# Optional. Hints to the retriever about the dominant taxonomy.
hierarchy: visual-hierarchy
# Optional. Multi-axis tags the retriever boosts on when intent matches.
axes:
- layout
- typography
- spacing
- color
- motion
- accessibility
# Optional. Default contract scaffolds applied when a method doesn't override.
contract:
typography: atom-12-array
color: atom-token-semantic
# Optional. L5 validator hooks (zero or more).
validators:
- name: html-semantic
checker: regex
pattern: '^<([a-z][a-z0-9]*)\b[^>]*>'
- name: color-token
checker: ai-judge
rubric: '@frontend-design/rubric-color-token'
# Optional. Default budget hints — used by the retriever when none specified.
budgets:
default-tokens: 1200
max-tokens: 2400 字段索引
| 字段 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
name | kebab-case 字符串 | 是 | 已加载领域间唯一。 |
version | semver | 是 | 跟你的 Prime 用同一套版本策略。 |
description | 字符串 | 是 | 市场列表里展示。 |
hierarchy | 字符串 | 否 | 给检索器关于主分类法的提示。 |
axes | 字符串列表 | 否 | 检索器按之加权的标签。可用 Unicode。 |
contract | map | 否 | 默认 contract 脚手架。 |
validators | validator 列表 | 否 | L5 钩子。 |
budgets | map | 否 | 默认 token 预算。 |
Validator 配置
v0.1.0 内置支持两种 checker。领域定制的 MCP wrapper 可以注册更多。
| Checker | 参数 | 做什么 |
|---|---|---|
regex | pattern | 对生成产物做匹配;至少匹配一次就通过。 |
ai-judge | rubric(atom id) | 把产物 + rubric 原子发给 LLM,解析 pass/fix 裁决。 |
发现规则
- 文件名必须是
domain.yaml,$PRIME_DIR下任何层级都行,最多 4 层深。 - 已加载领域间名字必须唯一。冲突在启动时硬抛错。
- 每个 server 进程加载一次。发
SIGHUP触发重载。
从 v0.0.x 的代码定义领域迁移
如果你有一个老 monorepo,里面有 packages/domain-foo/ 目录:
把它的 tag 列表搬到 axes、validator 搬到 validators,
然后作为 domain.yaml 丢到 corpus 根目录。运行时会自动捡起来。