Skill Wiki v0.1.0

文档 / usage / compile

本页目录

编译

编译会遍历 primes/sources/,把结果写入 primes/compiled/: 每个原子一个目录,外加一份全局 _index.xml

两种入口

# Single file — useful for iterating on one atom
prime compile primes/sources/@my/rule-x.prime

# Whole tree — what you ship
bun scripts/build-atom-dirs.ts \
  --src primes/sources \
  --out primes/compiled

# With L2 (LLM semantic check)
DEEPSEEK_API_KEY=sk-... \
  bun scripts/build-atom-dirs.ts \
    --src primes/sources \
    --out primes/compiled \
    --deep

产物结构

primes/compiled/
├── _index.xml                              ← always-loaded surface
└── @my/
    ├── rule-x/
    │   ├── atom.yaml                       ← metadata only
    │   ├── graph.yaml                      ← resolved edges
    │   └── chunks/
    │       ├── summary.md                  ← ~30 tok
    │       ├── core.md                     ← ~150 tok
    │       └── full.md                     ← ~380 tok
    └── term-y/
        ├── atom.yaml
        ├── graph.yaml
        └── chunks/...

输出保证

  • 幂等:同一份源码编译两次,产物字节级一致。
  • L2 有缓存:LLM 检查结果会写入 .l2-cache.json,未改动的原子不会重复花钱。
  • 逐原子隔离:原子 A 编译失败,不会影响原子 B 的产物。每个原子目录都是先写到临时位置再整体改名落地。

编译后检查

# List everything
prime list --dir primes/compiled

# Show one atom's full body
prime show @my/rule-x --dir primes/compiled

# Walk the dep tree from one seed
prime deps @my/method-foo --dir primes/compiled

# Print the index size
wc -c primes/compiled/_index.xml

持续编译

开发时可以监听文件变化,自动重新编译:

bun --watch scripts/build-atom-dirs.ts \
  --src primes/sources \
  --out primes/compiled

常见报错

报错原因修法
L1:必填字段缺失原子少了对应 kind 的必填字段补上即可,参考 Atoms
L1:未知 atom id @x/y边指向的原子并不存在把目标原子补出来,或删掉这条边
L3:requires 上检测到环A→B→C→A把其中一条边改成 see-also,破掉环
L3:validates-with 的 kind 不匹配边指向了错误的 kind把目标改成 sourcemetriccheck
L2:AI 客户端不可达缺 API key 或被限流去掉 --deep 跳过,或配上 key 重试