Skill Wiki v0.1.0

文档 / usage / first-atom

本页目录

第一个原子

1. 建工作目录

mkdir my-pack && cd my-pack
mkdir -p primes/sources/@my

2. 写第一个原子(一条 fact)

保存为 primes/sources/@my/fact-water-boils-at-100c.prime

fact WaterBoilsAt100C {
  id: "@my/fact-water-boils-at-100c"
  version: "1.0.0"
  description: "Pure water boils at 100°C at 1 atm."
  domain: physics

  statement: "At one atmosphere of pressure, pure water boils at 100°C (212°F)."
  confidence: 0.99
}

3. 写它会用到的 term

保存为 primes/sources/@my/term-celsius.prime

term Celsius {
  id: "@my/term-celsius"
  version: "1.0.0"
  description: "A unit of temperature where 0° = water freezing at 1 atm."
  domain: physics

  definition: "A temperature scale on which 0° is the freezing point of water and 100° is its boiling point at 1 atmosphere."
}

4. 写一条 requires 这两者的 rule

保存为 primes/sources/@my/rule-altitude-affects-boiling.prime

rule AltitudeAffectsBoiling {
  id: "@my/rule-altitude-affects-boiling"
  version: "1.0.0"
  description: "Boiling point drops ~0.3°C per 100 m of altitude."
  domain: physics

  claim: "Above 1 atm, water boils below 100°C; the loss is ~0.3°C per 100 m."
  applies-to: [cooking, climbing, science]
  severity: informational

  requires: [
    @my/term-celsius,
    @my/fact-water-boils-at-100c,
  ]

  validates-with: [
    @my/source-nist-water-properties,
  ]
}

5. 编译

目录级编译脚本住在 prime-system 仓库里(见 安装)。从那个仓库里跑, --src / --out 指向这个工作目录:

# 在你的 prime-system clone 里跑
bun /abs/path/to/prime-system/scripts/build-atom-dirs.ts \
  --src /abs/path/to/my-pack/primes/sources \
  --out /abs/path/to/my-pack/primes/compiled

# → output:
#   primes/compiled/@my/fact-water-boils-at-100c/{atom.yaml, chunks/}
#   primes/compiled/@my/term-celsius/{atom.yaml, chunks/}
#   primes/compiled/@my/rule-altitude-affects-boiling/{atom.yaml, chunks/}
#   primes/compiled/_index.xml

说明:原生的 prime compile --dir <src> --out <dst> 子命令已在路线图上, 将来会替代上面的脚本调用。

L1 会抓到 @my/source-nist-water-properties 这条引用不存在(你还没写它)。两种处理方式:

  1. 把它写出来,或
  2. 暂时去掉那行 validates-with,再编一次。

6. 检视

prime list --dir primes/compiled
# → @my/fact-water-boils-at-100c            fact
# → @my/term-celsius                        term
# → @my/rule-altitude-affects-boiling       rule

prime show @my/rule-altitude-affects-boiling --dir primes/compiled
# Prints kind, fields, edges out, edges in.

cat primes/compiled/@my/rule-altitude-affects-boiling/chunks/summary.md
# Prints the ~30-token summary.

7. 启动 MCP server

PRIME_DIR=$PWD/primes/compiled \
  bun /abs/path/to/prime-system/packages/mcp-server-core/src/index.ts
# Server up on stdio. Wire it into Claude Code (next page).