本页目录
Projection · 3 个层级
让 agent 自己决定加载多少。三个层级,按 kind 切分,确定性的 chunker。
三个层级
| 层级 | Token 预算 | 何时加载 | 包含 |
|---|---|---|---|
summary | 约 30 tok | 始终 —— 已经在 _index.xml 里 | description + tags + 一行 claim |
core | 约 150 tok | 作为相邻 / 支撑原子被检中 | + 关键 body 字段(claim、applies-to、severity) |
full | 约 380 tok | 作为直接命中 / 聚焦原子被检中 | + sources、examples、remediation、exceptions |
agent 通过 MCP 工具按 query 选择 level:
prime_query({
scope: "focus:input-validation",
level: "core", // ← summary | core | full
tags: ["api-endpoint"],
budget_tokens: 800,
}) 图 · 投影模型

Chunker 知道 kind
summary 里写什么,要看 kind。一条 rule 的 summary 是它的 claim;
一个 method 的 summary 是它的 goal;一条 fact 的 summary 是它的 statement。
Chunker(packages/compiler/src/chunker.ts)按原子走 AST:
// packages/compiler/src/chunker.ts (signature)
export interface ChunkLevels {
/** ~30 tok: description + tags + 1-line claim */
summary: string;
/** ~150 tok: + core body fields */
core: string;
/** ~380 tok: + sources + examples + relations + notes */
full: string;
}
export function chunk(atom: AtomDeclaration): ChunkLevels { ... } 每种 kind 的切分规则
| Kind | summary | core | full |
|---|---|---|---|
rule | The claim | + applies-to、severity | + remediation、exceptions、validates-with |
pattern | 问题陈述 | + solution + structure | + examples、behaviours |
fact | Statement | + confidence + applies-to | + sources、counter-conditions |
method | Goal | + 关键 steps | + contract、tools、examples |
persona | Posture | + voice + style hooks | + examples、anti-patterns |
编译产物布局
compiled/
└── @scope/
└── kind-name/
├── atom.yaml # metadata only
├── graph.yaml # resolved edges
└── chunks/
├── summary.md # ~30 tok
├── core.md # ~150 tok
└── full.md # ~380 tok
运行时不读 chunks/。MCP server 返回路径;agent 用自己的 Read 工具去读。
为什么恰好三层?
两层不够 —— agent 需要"index 里的 summary" + "命中相邻时的 core" + "聚焦原子的 full"。 四层多余 —— 第三层已经能装下所有 core 装不下的东西。 经验上(参考实现 + 示例 Prime 共编译过约 12 个 corpus),三层切分还没有需要扩展过。