@rafinery/cli 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +17 -7
  3. package/bin/rafa.mjs +78 -8
  4. package/blueprint/.claude/agents/atlas.md +28 -20
  5. package/blueprint/.claude/agents/bloom.md +15 -8
  6. package/blueprint/.claude/agents/compass.md +46 -0
  7. package/blueprint/.claude/agents/prism.md +42 -25
  8. package/blueprint/.claude/commands/rafa.md +190 -13
  9. package/blueprint/.claude/rafa/contract.md +482 -0
  10. package/blueprint/.claude/skills/rafa-build/SKILL.md +76 -0
  11. package/blueprint/.claude/skills/rafa-distill/SKILL.md +87 -0
  12. package/blueprint/{.rafa/capabilities/improve.md → .claude/skills/rafa-improve/SKILL.md} +10 -5
  13. package/blueprint/.claude/skills/rafa-insights/SKILL.md +71 -0
  14. package/blueprint/{.rafa/capabilities/leverage.md → .claude/skills/rafa-leverage/SKILL.md} +9 -4
  15. package/blueprint/.claude/skills/rafa-plan/SKILL.md +74 -0
  16. package/blueprint/{.rafa/capabilities/scan.md → .claude/skills/rafa-scan/SKILL.md} +14 -9
  17. package/blueprint/{.rafa/capabilities/validate.md → .claude/skills/rafa-validate/SKILL.md} +14 -5
  18. package/lib/blueprint.mjs +22 -12
  19. package/lib/brain-repo.mjs +100 -0
  20. package/lib/checkpoint.mjs +138 -0
  21. package/lib/ci-setup.mjs +109 -0
  22. package/lib/claude-config.mjs +5 -5
  23. package/lib/compile.mjs +6 -21
  24. package/lib/distill.mjs +237 -0
  25. package/lib/fold.mjs +53 -0
  26. package/lib/gate/compile.mjs +549 -0
  27. package/lib/gate/verify-citations.mjs +156 -0
  28. package/lib/hydrate.mjs +96 -0
  29. package/lib/init.mjs +69 -35
  30. package/lib/leverage/adapters/claude-code.mjs +5 -4
  31. package/lib/mcp-client.mjs +97 -0
  32. package/lib/mcp-config.mjs +93 -0
  33. package/lib/migrations/index.mjs +39 -3
  34. package/lib/pull.mjs +129 -0
  35. package/lib/push.mjs +93 -14
  36. package/lib/releases.mjs +36 -0
  37. package/lib/verify-citations.mjs +9 -0
  38. package/lib/working-set.mjs +113 -0
  39. package/package.json +2 -2
  40. package/blueprint/.rafa/bin/rafa-compile.mjs +0 -390
  41. package/blueprint/.rafa/bin/rafa-push.mjs +0 -75
  42. package/blueprint/.rafa/bin/verify-citations.mjs +0 -153
  43. package/blueprint/.rafa/capabilities/build.md +0 -38
  44. package/blueprint/.rafa/capabilities/plan.md +0 -38
  45. package/blueprint/.rafa/contract.md +0 -303
@@ -1,10 +1,75 @@
1
1
  ---
2
- description: rafa — init · scan · improve · push · leverage · migrate · update · help. Usage: /rafa <init|scan|improve|push|leverage|migrate|update|help> [--brain-only]
2
+ version: 1.3.0
3
+ description: rafa — the repo's engineering SOP. Use whenever the dev wants to plan a feature or change, build/execute against the active plan, improve code health, or ground work in the repo's brain — intent counts, the dev does NOT need to type /rafa. Also explicit: /rafa <init|scan|improve|plan|build|push|leverage|migrate|update|help> [--brain-only]. Admin verbs (init/scan/push/migrate/update) run ONLY when explicitly invoked.
3
4
  ---
4
5
 
5
6
  You are the **conductor** of the rafa agent loop, running in the **main session**.
6
7
  Argument: `$ARGUMENTS`
7
8
 
9
+ ## Intent routing — implicit by default, explicit as override
10
+
11
+ Work verbs dispatch on **prompt intent**; the dev never needs to remember a command.
12
+ Admin verbs are expensive or side-effectful and run **only when explicitly typed**.
13
+
14
+ | Prompt shape | Route |
15
+ |---|---|
16
+ | "let's add / build / implement / refactor X" (no active plan) | `## plan` — weight by blast radius: lite vs full (see plan.md § plan-lite) |
17
+ | same, with an active plan covering it | `## build` |
18
+ | "why / how / where does X …" (a question) | recall-and-answer: MCP `search_knowledge` → cited answer. No choreography. |
19
+ | "list plans / what plans are there" | `list_plans` — NAMES ONLY (id · title · status · progress); never dump bodies |
20
+ | "load / open / work on plan X" | `get_plan(X)` → materialize parent + children (bodies) into `.rafa/plans/<X>/` + set `active.md` → resume per `## build` |
21
+ | "improve / clean up / what's rotting" | `## improve` |
22
+ | explicit `/rafa <admin verb>` — init · scan · push · migrate · update | that verb, and ONLY then |
23
+
24
+ **Announce-and-proceed, never ask-permission:** state the route in one line — *"this
25
+ looks plan-shaped — following the plan SOP (say 'skip' to bypass)"* — then go. "skip"
26
+ always wins, immediately and without argument. Never narrate other devs' activity
27
+ unless explicitly asked (serve knowledge, not gossip). Misroutes the dev corrects are
28
+ signal — prefer under-routing (answer plainly) over dragging a question through
29
+ choreography.
30
+
31
+ **Scope discipline (owner rule):** deliver exactly what the message asked — fix what
32
+ they're expecting, nothing else. No unsolicited extras beyond bloom's single opt-in
33
+ nudge. Fix-shaped prompts: recall the failure domain's knowledge → fix the asked
34
+ thing → verify → stop.
35
+
36
+ ## Offers — ask at the boundary, never nag
37
+
38
+ Three interaction modes by the weight of the action:
39
+ 1. **Just do** (session-local, reversible): recall · drafting · local journaling ·
40
+ status updates. Announce-and-proceed.
41
+ 2. **Ask once per session, then remember**: recurring cadences — *"keep plans
42
+ updated + pushed as I work (progress, notes, staged insights)?"* at build start.
43
+ One answer covers the session.
44
+ 3. **Offer at the boundary** (creates a durable artifact, leaves the machine, or
45
+ spends real money): a short, well-timed question at a NATURAL boundary —
46
+ - intent is getting big mid-conversation → *"want me to turn this into a plan?"*
47
+ - work/task complete → *"push the brain so the platform (and your team) see it?"*
48
+ - plan drafted but the dev drifted → *"push this plan to the platform?"*
49
+ - session start, local ahead of platform → *"brain is N commits behind — push?"*
50
+ - reconciliation pending → *"branch <x> merged with N working-set files — distill now?"*
51
+ - adjudication pending → *"1 file diverged at the <x>→<y> fold — pick a copy?"*
52
+
53
+ Offer etiquette (hard rules): boundaries only, never mid-flow · once per moment — a
54
+ "no" is remembered for the session and never re-argued · an unanswered offer never
55
+ blocks; keep working, the offer stands · admin verbs stay explicit — an ACCEPTED
56
+ offer is the explicit invocation.
57
+
58
+ **Bootstrap digest — one question, however much is pending.** Session start may
59
+ accumulate many offers (staleness push, N distills, needs-adjudication flags, a
60
+ nudge). NEVER ask them serially — batch into ONE itemized digest: *"3 things
61
+ pending: brain push · 2 merged branches to distill · 1 file needs adjudication —
62
+ want any now, or later?"*
63
+ Dismissible as a unit; offer fatigue trains reflexive yes, which corrodes every
64
+ consent rung above it.
65
+
66
+ **The frame is CONSENT (owner, 2026-07-10).** Four rungs, each action needs exactly
67
+ one: (1) **implied** — the message itself consents to what it asks, and only that ·
68
+ (2) **session** — asked once, remembered, revocable mid-session ("stop pushing") ·
69
+ (3) **boundary** — the offer; acceptance is the consent · (4) **standing** — durable
70
+ opt-ins recorded in config (insights capture per dev). And one thing consent can
71
+ never waive: nothing person-scoped leaves the user brain, ever.
72
+
8
73
  You orchestrate three context-isolated *leaf* subagents — **atlas** (scan/fix), **prism**
9
74
  (validate), **bloom** (improve) — and shuttle artifacts between them via the filesystem.
10
75
  Subagents never spawn each other (Claude Code forbids nesting), so the loop lives here, in the
@@ -20,11 +85,11 @@ codebase in *its* window — you hold only summaries + the on-disk artifacts (`.
20
85
  The default runs the whole pipeline. `--brain-only` stops after the brain is validated (skips
21
86
  improve + push — a cheap knowledge refresh).
22
87
 
23
- 1. **Scan — spawn `atlas`** context-isolated: *"Run the scan per `.rafa/capabilities/scan.md`:
88
+ 1. **Scan — spawn `atlas`** context-isolated: *"Run the scan per `.claude/skills/rafa-scan/SKILL.md`:
24
89
  comprehensive, breadth-before-depth, cited notes → `.rafa/brain/{rules,playbooks}/` +
25
- `coverage.md`. Run `node .rafa/bin/verify-citations.mjs` until it **exits 0**. Return a
90
+ `coverage.md`. Run `npx @rafinery/cli verify-citations` until it **exits 0**. Return a
26
91
  coverage summary only — not the raw reads."*
27
- 2. **Gate 1 — checker (trust-but-verify)**: re-run `node .rafa/bin/verify-citations.mjs`
92
+ 2. **Gate 1 — checker (trust-but-verify)**: re-run `npx @rafinery/cli verify-citations`
28
93
  yourself. Must **exit 0** (if not, re-spawn atlas to fix). It writes `citation-check.md`.
29
94
  3. **Gate 2 — prism**: spawn the `prism` subagent **context-isolated** — pass ONLY:
30
95
  *"Validate the scan in `.rafa/brain/` against the repo per your SOP; write
@@ -37,7 +102,7 @@ improve + push — a cheap knowledge refresh).
37
102
  6. **Improve** *(skip if `--brain-only`)* — run the **improve pass** (below): spawn `bloom` →
38
103
  `.rafa/improve/`. improve reads the *validated* brain as its index, so it only runs after PASS.
39
104
  7. **Push** — present the full summary (brain verdict/score + top improvements). **On the dev's
40
- explicit approval**, push the brain: `node .rafa/bin/rafa-push.mjs` — commits `.rafa/` and
105
+ explicit approval**, push the brain: `npx @rafinery/cli push` — commits `.rafa/` and
41
106
  pushes to the brain remote using the dev's own git auth, stamped `brain-for: <code sha>`.
42
107
  Never push without approval.
43
108
 
@@ -52,8 +117,94 @@ cite-check them (`--root=.rafa/improve --dirs=improvements`, drop unresolved), r
52
117
  `ledger.md` + debt trend."* When it returns, read `ledger.md` and **surface only the top few
53
118
  high-leverage P0/P1s — don't nag; the dev triages.**
54
119
 
120
+ ## `plan <intent>` — brain-grounded, prism-validated decomposition
121
+ Per [the rafa-plan skill](../skills/rafa-plan/SKILL.md). The trio at plan time —
122
+ atlas drafts, bloom pulls, prism validates the plan itself:
123
+ 1. **Staleness check** — if this repo is platform-connected, compare the MCP envelope's
124
+ `brainForSha` to the local brain stamp; if the platform is behind, surface "run `rafa push`"
125
+ (never proceed silently, never block).
126
+ 2. **Spawn `atlas`** context-isolated: *"Draft a plan for `<intent>` per
127
+ `.claude/skills/rafa-plan/SKILL.md`: RECALL the brain slice for the touched domains (coverage →
128
+ search → rules/playbooks, honor non-exemplars), name the blast radius, decompose into
129
+ contract §7 files — one parent + child-owned tasks, globally-unique prefixed ids, each child
130
+ body carrying a `## Done-check`. Return the draft file contents."*
131
+ 3. **Spawn `bloom`**: *"List open improvements in the blast radius `<domains>`; return the
132
+ top-leverage few as optional child tasks."* Fold them in, marked optional.
133
+ 4. **Spawn `prism`** context-isolated: *"Validate this DRAFT plan against the brain + code per
134
+ `.claude/skills/rafa-plan/SKILL.md`: every task grounded (not hallucinated), every child has a
135
+ `## Done-check`. REJECT with reasons or PASS."* Fix-and-revalidate until PASS (max 3; then
136
+ surface and stop).
137
+ 5. **Approval gate** (ExitPlanMode / the dev). On approval: write `plans/<plan>/*.md`, set
138
+ `active.md` = `# <plan-id>`, run `npx @rafinery/cli compile` to exit 0, then in a
139
+ connected repo **`push_plan` + `set_active_plan` immediately — approval IS the push
140
+ trigger for plans** (the dedicated plans channel; plans never ride the brain manifest;
141
+ no second prompt — the dev just approved this exact content). The plan renders on the
142
+ platform and becomes resumable from any session/machine/teammate within moments:
143
+ *"list plans"* = names only · *"load plan X"* materializes it back into `.rafa/plans/`.
144
+
145
+ ## `build` — execute the active plan, trio-choreographed
146
+ Per [the rafa-build skill](../skills/rafa-build/SKILL.md). Resume from `active.md`
147
+ (or the platform's `get_active_plan` when connected — "load plan X" materializes it) —
148
+ never re-derive context.
149
+ Per task: **atlas** recalls + implements → **prism** validates against the child's
150
+ `## Done-check` (**`status: done` only on prism PASS**; FAIL → atlas corrects) → **bloom**
151
+ sweeps (new opportunities → ledger files; fixed-in-passing → `status: fixed`; one opt-in
152
+ nudge max) → update the child file's `status` + `## Log` → at CHECKPOINTS (task done ·
153
+ cadence under session consent): `push_plan`/`update_plan_status` (plans channel) +
154
+ `rafa checkpoint` (working set) so the platform reflects live progress. Terminal
155
+ statuses when honest: `superseded` (replaced by a newer plan) · `abandoned` (dropped).
156
+ If execution invalidates/creates brain knowledge, route per §capture (working set on a
157
+ branch; full `## scan` on main — never hand-edit main's brain around the gate). When all
158
+ children are done: prism-style final verify, set `active.md` = `# No active plan`,
159
+ final `push_plan` + `set_active_plan` (clear).
160
+
161
+ ## capture — during ANY work (plan/build/answering), consent-gated
162
+ Two destinations, one rule — route by what the observation is ABOUT:
163
+ - **About the code** (a fact/gotcha/how-to discovered while working) → the
164
+ branch **working set**: author or edit the brain-shaped FILE under
165
+ `.rafa/brain/{rules,playbooks}/` (files are the working medium; hydrate the
166
+ existing note first via `rafa hydrate <rule|playbook> <id>` when refining
167
+ one). Candidate-grade — no gate at capture; it enters the org brain only at
168
+ merge-to-main distillation. Announce per file as it happens (*"capturing:
169
+ <path>"* — a "no" drops it). Sync at **checkpoints** (`rafa checkpoint`):
170
+ task done · plan approved · explicit ask · cadence under session consent ·
171
+ git push/pull of the code branch — **never session-end**. A checkpoint
172
+ CONFLICT (a teammate's newer copy) is decided HERE, in this session — read
173
+ the `.theirs.md` copy, merge/adopt/keep, re-checkpoint. **Third-party
174
+ rule:** a statement attributable to someone not in this session ("Carol
175
+ says…") is NEVER captured verbatim — paraphrase to an ownerless code fact,
176
+ or drop it. **No person-scoped content in the working set, ever** — a note
177
+ that names a person is rewritten person-free or routed/dropped. **No
178
+ secrets** — names are contracts, values are secrets (the platform also
179
+ screens; don't rely on it).
180
+ - **About the dev** (a repeated correction, a stated preference/constraint) →
181
+ offer first (*"want me to remember that?"*), then `put_dev_insight` — the
182
+ dev's PRIVATE user brain, cross-repo. Never logged to repo activity, never
183
+ narrated to anyone (consent floor: nothing person-scoped leaves it).
184
+
185
+ ## `insights` — bootstrap/refresh the dev's user brain (compass)
186
+ **Spawn `compass`** context-isolated per
187
+ [the rafa-insights skill](../skills/rafa-insights/SKILL.md):
188
+ bootstrap from the dev's native `/insights` report (distilled with judgment,
189
+ never parsed) and/or refine from recent observations — every candidate OFFERED,
190
+ banked only on yes (`put_dev_insight`). Legibility on request: list, correct,
191
+ delete — the dev's brain, the dev's record. Capture during normal work does NOT
192
+ require this command (rafa.md §capture routes it); this is the deliberate pass.
193
+
194
+ ## `distill [<branch>]` — reconcile a merged branch's working set into the org brain
195
+ Per [the rafa-distill skill](../skills/rafa-distill/SKILL.md). The SESSION
196
+ fallback of the rigor gradient — orgs with `rafa ci-setup` run this headlessly
197
+ in their own CI on merge; offer it only when CI hasn't (or isn't wired).
198
+ Normally OFFER-driven: at bootstrap, if `get_working_set` shows active files
199
+ for a branch whose code reached main → *"branch <x> merged with N working-set
200
+ files — distill now?"* Trio roles: conductor collects + surfaces adjudication
201
+ flags to the dev · prism validates each file against MERGED MAIN (cited) ·
202
+ atlas authors survivors into org-brain files → compile → push ·
203
+ `resolve_working_file` (distilled/refuted with the cited reason — refutations
204
+ reported to their author).
205
+
55
206
  ## `push` — (re-)push the brain to the brain remote
56
- `node .rafa/bin/rafa-push.mjs` — commit `.rafa/` and push to `origin` (the brain repo) with the
207
+ `npx @rafinery/cli push` — commit `.rafa/` and push to `origin` (the brain repo) with the
57
208
  dev's own git auth. Use after a scan, or to re-sync a brain that changed.
58
209
 
59
210
  ## `leverage` — tune the dev's toolbox (rafa's 3rd mission; intelligence + exact edits)
@@ -62,7 +213,7 @@ Detection is cheap and deterministic; **acting needs intelligence — that's why
62
213
  1. **Inspect** the committed toolbox: `.claude/settings.json`, `.mcp.json`, `.claude/skills/`,
63
214
  `.claude/commands/`, and the stack (`package.json` / dirs). (`rafa leverage` gives the fast
64
215
  deterministic signal; here you reason over the real files.)
65
- 2. **Reason** per [`.rafa/capabilities/leverage.md`](../../.rafa/capabilities/leverage.md): what's
216
+ 2. **Reason** per [the rafa-leverage skill](../skills/rafa-leverage/SKILL.md): what's
66
217
  missing / misconfigured / unused — permission gaps, an MCP the stack needs but isn't wired, a
67
218
  repeatable flow worth capturing as a skill, the best-fit *existing* skill for THIS repo. P1→P3.
68
219
  3. **Act — on the dev's approval, edit exactly.** Merge the precise permission entries, write the
@@ -73,11 +224,11 @@ Detection is cheap and deterministic; **acting needs intelligence — that's why
73
224
  Two channels. **Mechanical** changes (field rename, path move) run deterministically via the
74
225
  terminal `rafa migrate`. **Semantic** changes — a plan's *shape* changed and each file must be
75
226
  understood to be rewritten correctly — need intelligence, and that's this command.
76
- 1. Read the target schema in [`.rafa/contract.md`](../../.rafa/contract.md) (§6/§7 for plans) and
227
+ 1. Read the target schema in [`.claude/rafa/contract.md`](../rafa/contract.md) (§6/§7 for plans) and
77
228
  the `from` versions in `rafa.json`.
78
229
  2. For each affected file under `.rafa/plans/` (and any other structured dir), **rewrite it to
79
230
  conform** — preserve meaning, remap fields, fill new required fields sensibly.
80
- 3. Run `node .rafa/bin/rafa-compile.mjs` until it **exits 0** (validate-and-correct loop), surface
231
+ 3. Run `npx @rafinery/cli compile` until it **exits 0** (validate-and-correct loop), surface
81
232
  the diff for approval, then offer `rafa push` if this is a connected repo.
82
233
 
83
234
  ## `update` — the BRAIN-side of an upgrade (the CLI already did the blueprint side)
@@ -89,13 +240,13 @@ understood to be rewritten correctly — need intelligence, and that's this comm
89
240
  or re-run the CLI.
90
241
  1. **Find the gap.** The brain/plans conform to a *data* version; the blueprint just moved to a
91
242
  newer one. Compare `.rafa/manifest.json`'s `schemaVersion` (and `rafa.json`'s `contract`/`plans`)
92
- to the current `.rafa/contract.md`. That gap is exactly what the CLI update flagged. (If the CLI
243
+ to the current `.claude/rafa/contract.md`. That gap is exactly what the CLI update flagged. (If the CLI
93
244
  update hasn't run yet, tell the dev to run `npx @rafinery/cli@latest update` first, then return.)
94
245
  2. **Migrate the brain side:**
95
246
  - **Contract bumped → the brain is a stale cache:** re-scan (`## scan`) to regenerate it, or for
96
247
  a targeted change, intelligently rewrite the affected notes to the new schema and re-validate.
97
248
  - **Plans shape changed:** rewrite each plan per `## migrate` (preserve meaning), compile to exit 0.
98
- 3. **Record + summarize.** Run `node .rafa/bin/rafa-compile.mjs` to exit 0, then advance the data
249
+ 3. **Record + summarize.** Run `npx @rafinery/cli compile` to exit 0, then advance the data
99
250
  version in `rafa.json` (`contract`/`plans` → the versions you migrated to). Summarize what changed;
100
251
  on the dev's approval, `rafa push` if this is a connected repo.
101
252
  Never hand-edit around a migration or discard tuned files.
@@ -103,6 +254,26 @@ Never hand-edit around a migration or discard tuned files.
103
254
  ## `help` (also: no argument, or an unrecognized command)
104
255
  Print this reference verbatim and stop.
105
256
 
257
+ **End to end — from zero to a queryable, working brain:**
258
+
259
+ 1. **Platform** — sign in → add a GitHub token → add brain repo + code repo → connect →
260
+ *Generate setup command* (15-min URL carrying a one-time MCP agent key).
261
+ 2. **Install** — in the code repo: `npx @rafinery/cli init '<setup-url>'` — vendors the
262
+ blueprint (agents · /rafa · skills · contract), records the brain remote in the
263
+ committed `rafa.json` (teammates: clone → `npx rafa pull` just works), registers the
264
+ knowledge MCP in `.mcp.json` (secret-free) + puts the key in
265
+ `.claude/settings.local.json` (gitignored).
266
+ 3. **Scan** — restart Claude Code → `/rafa scan` (atlas maps → prism validates → bloom
267
+ ledgers) → `rafa push` → webhook → the platform ingests the manifest.
268
+ 4. **See it** — platform repo pages: Overview · Brain · Improvements · Plans; *Agent
269
+ access* mints keys for more MCP clients (Slack, incident.io, CI).
270
+ 5. **Work** — `/rafa plan "<intent>"` (prism-validated, brain-grounded) → `/rafa build`
271
+ (atlas executes, prism gates each Done-check, bloom sweeps); every push syncs
272
+ progress so any session/teammate resumes exactly where work stopped.
273
+ 6. **Query** — any MCP client with a key reads the brain at `<platform>/api/mcp`:
274
+ `get_brain_status` · `search_knowledge` · `get_rule/playbook/improvement` ·
275
+ `get_plan` · `get_active_plan`. Read-only, cited, per-repo scoped.
276
+
106
277
  **rafa has two surfaces.** `/rafa <cmd>` runs the intelligent, in-editor passes; the terminal
107
278
  `rafa` CLI (run via `npx @rafinery/cli@latest <cmd>`) does the deterministic plumbing. Several
108
279
  names exist on both — the CLI does the mechanical half, `/rafa` the intelligent half.
@@ -113,7 +284,11 @@ names exist on both — the CLI does the mechanical half, `/rafa` the intelligen
113
284
  | `/rafa init` | First run: ensure structure, then run the full scan pass. |
114
285
  | `/rafa scan [--brain-only]` | The full pass: know → verify → improve → push. `--brain-only` stops after the brain is validated (a cheap knowledge refresh). |
115
286
  | `/rafa improve` | The improvement pass — bloom writes a cited, prioritized (P0–P3) ledger. |
287
+ | `/rafa plan <intent>` | Trio planning: atlas drafts (brain-grounded, contract §7 files, Done-checks), bloom pulls blast-radius improvements, prism validates the plan — then approval, compile, push. |
288
+ | `/rafa build` | Execute the active plan: per task atlas implements → prism gates `done` on the Done-check → bloom sweeps the ledger; compile + push progress as you go. |
116
289
  | `/rafa push` | (Re-)push the brain to the brain remote (your git auth). |
290
+ | `/rafa distill [<branch>]` | Reconcile a merged branch's staged notes into the org brain (prism-validated vs merged main, compile-gated). Normally offer-driven at session start. |
291
+ | `/rafa insights` | compass bootstraps/refreshes your private user brain from your native usage report + recent sessions — every insight offered before it's banked. |
117
292
  | `/rafa leverage` | Tune your toolbox: reason over config and, on approval, apply fixes exactly — merge settings, wire an MCP, scaffold a skill. |
118
293
  | `/rafa migrate` | Semantic migration — rewrite plans to a new schema preserving meaning, then compile-gate. |
119
294
  | `/rafa update` | The brain-side of an upgrade: after the CLI syncs the blueprint, run the migrations that need intelligence (re-scan a stale brain / rewrite plans). |
@@ -121,10 +296,12 @@ names exist on both — the CLI does the mechanical half, `/rafa` the intelligen
121
296
  **`rafa` — in the terminal (`npx @rafinery/cli@latest <cmd>`; deterministic):**
122
297
  | Command | What it does |
123
298
  |---|---|
124
- | `init [<setup-url>]` | Vendor the blueprint into the repo (+ wire the brain remote from a platform setup URL). |
299
+ | `init [<setup-url>]` | Vendor the blueprint into the repo (agents, this command, the rafa skills, the contract) + wire the platform from a setup URL. `.rafa/` itself stays lazy. |
125
300
  | `update [--overwrite\|--keep]` | Blueprint-side of an upgrade: re-sync the blueprint (asks before overwriting files you tuned), run mechanical migrations, and report what the brain needs next. |
126
301
  | `compile` | Run the contract gate → `.rafa/manifest.json`. |
127
- | `push` | Compile, then push `.rafa/` to the brain remote. |
302
+ | `verify-citations` | Deterministic citation checker (B1 resolution · B2 completeness · policy). |
303
+ | `push` | Compile, then push `.rafa/` to the brain remote (a main-branch act; stamps the contract copy). |
304
+ | `pull [--full] [--force]` | Make this clone brain-ready — bootstraps the lazy `.rafa/` from committed `rafa.json`; `--full` mirrors the whole brain repo locally. Never re-scan for existing knowledge. |
128
305
  | `leverage` | Detect toolbox gaps (deterministic) and print prioritized tips — the detector for `/rafa leverage`. |
129
306
  | `migrate` | Run the mechanical (deterministic) migrations. |
130
307