On this page
Compile
Compilation walks primes/sources/ and emits primes/compiled/
— one directory per atom plus the global _index.xml.
Two entry points
# 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 What gets written
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/... Output guarantees
- Idempotent: compiling the same sources twice produces byte-identical output.
- L2-cached: LLM check results are stored in
.l2-cache.json; unchanged atoms don't re-pay. - Atomic per atom: a compile failure in atom A doesn't corrupt atom B's output. Each atom directory is written then renamed.
Inspect after compile
# 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 Continuous compile
For development, watch + recompile:
bun --watch scripts/build-atom-dirs.ts \
--src primes/sources \
--out primes/compiled Common errors
| Error | Cause | Fix |
|---|---|---|
| L1: required field missing | Atom doesn't have a kind-required field | Add it; see Atoms |
L1: unknown atom id @x/y | Edge points to a non-existent atom | Author the target or remove the edge |
L3: cycle detected in requires | A→B→C→A | Break the cycle by replacing one edge with see-also |
L3: kind mismatch on validates-with | Edge points to wrong kind | Use source/metric/check as the target |
| L2: AI client unreachable | API key missing or rate-limited | Run without --deep or set the key |