Skill Wiki v0.1.0

文档 / spec / projection

本页目录

Projection · 3 个层级

让 agent 自己决定加载多少。三个层级,按 kind 切分,确定性的 chunker。

三个层级

层级Token 预算何时加载包含
summary约 30 tok始终 —— 已经在 _index.xmldescription + 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,
})

图 · 投影模型

Projection model — existence is not content; agent picks summary, core, or full

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 的切分规则

Kindsummarycorefull
ruleThe claim+ applies-to、severity+ remediation、exceptions、validates-with
pattern问题陈述+ solution + structure+ examples、behaviours
factStatement+ confidence + applies-to+ sources、counter-conditions
methodGoal+ 关键 steps+ contract、tools、examples
personaPosture+ 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),三层切分还没有需要扩展过。