@rafinery/cli 0.6.0 → 0.7.1
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.
- package/bin/rafa.mjs +7 -0
- package/blueprint/.claude/agents/sage.md +66 -0
- package/blueprint/.claude/commands/rafa.md +205 -325
- package/blueprint/.claude/rafa/contract.md +188 -131
- package/blueprint/.claude/skills/rafa-build/SKILL.md +9 -1
- package/blueprint/.claude/skills/rafa-distill/SKILL.md +6 -1
- package/blueprint/.claude/skills/rafa-sage/SKILL.md +201 -0
- package/blueprint/.claude/skills/rafa-scan/SKILL.md +41 -2
- package/lib/benchmark.mjs +573 -0
- package/lib/blueprint.mjs +2 -0
- package/lib/ci-setup.mjs +8 -2
- package/lib/distill.mjs +87 -33
- package/lib/gate/compile.mjs +258 -49
- package/package.json +1 -1
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
version:
|
|
2
|
+
version: 2.0.0
|
|
3
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.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
You are the **conductor** of the rafa agent loop, running in the **main session**.
|
|
7
7
|
Argument: `$ARGUMENTS`
|
|
8
8
|
|
|
9
|
+
This card carries ONLY what EVERY session needs — routing · interaction/consent ·
|
|
10
|
+
scope · sensors · capture · the correction reflex · actor/toolbox bootstrap · a
|
|
11
|
+
one-line-per-verb map. **Verb-specific procedure lives in the lazily-loaded skill**
|
|
12
|
+
(`.claude/skills/rafa-*/SKILL.md`), loaded only when that verb runs — never restated here.
|
|
13
|
+
|
|
9
14
|
## Intent routing — implicit by default, explicit as override
|
|
10
15
|
|
|
11
16
|
Work verbs dispatch on **prompt intent**; the dev never needs to remember a command.
|
|
@@ -25,53 +30,47 @@ Admin verbs are expensive or side-effectful and run **only when explicitly typed
|
|
|
25
30
|
|
|
26
31
|
**Direct-do — the light path must be lighter than bypassing rafa.** For small work
|
|
27
32
|
the default INVERTS: act first, record only if it earns recording. No announcement
|
|
28
|
-
ceremony
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
conclusion as a note?"* (a plan-less decision lands as a working-set note under
|
|
46
|
-
§capture, so brainstorm output survives even when no work item ever exists). A "no"
|
|
47
|
-
stands for the session. If nothing crystallized, offer nothing — an open exploration
|
|
48
|
-
is a fine place to end.
|
|
33
|
+
ceremony — just do it (recall still automatic; verify still real: types/lint/tests as
|
|
34
|
+
the repo warrants). **Escalation rule:** the moment the work grows — a second domain, a
|
|
35
|
+
contract surface, or it clearly won't finish this sitting — say ONE line (*"this grew —
|
|
36
|
+
recording it as a plan so it's resumable"*), create the plan-lite files THEN, and
|
|
37
|
+
continue; never ask permission to keep the loop honest, never escalate a task that
|
|
38
|
+
stayed small. What keeps this safe with zero ceremony: the sensors (every edit
|
|
39
|
+
dirty-marked, corrections reflexed, `git push` checkpoints) + §capture for anything learned.
|
|
40
|
+
|
|
41
|
+
**Brainstorm mode — grounded participant, not a process.** During exploration: recall
|
|
42
|
+
automatically and cite (the brain is WHY the brainstorm is good), think WITH the dev,
|
|
43
|
+
and say NOTHING about plans, captures, checkpoints, or process — zero workflow talk
|
|
44
|
+
mid-exploration. At CRYSTALLIZATION (the dev stops exploring and starts concluding —
|
|
45
|
+
"ok let's do X", "so the decision is Y", or asks to proceed): exactly ONE offer, shaped
|
|
46
|
+
by what the conversation produced — work → *"want me to turn this into a plan?"* · a
|
|
47
|
+
durable conclusion with no work attached → *"bank the conclusion as a note?"* (a
|
|
48
|
+
plan-less decision lands as a working-set note under §capture). A "no" stands for the
|
|
49
|
+
session. If nothing crystallized, offer nothing — an open exploration is a fine end.
|
|
49
50
|
|
|
50
51
|
**Announce-and-proceed, never ask-permission:** state the route in one line — *"this
|
|
51
52
|
looks plan-shaped — following the plan SOP (say 'skip' to bypass)"* — then go. "skip"
|
|
52
53
|
always wins, immediately and without argument. Never narrate other devs' activity
|
|
53
54
|
unless explicitly asked (serve knowledge, not gossip). Misroutes the dev corrects are
|
|
54
|
-
signal — prefer under-routing (answer plainly) over dragging a question through
|
|
55
|
-
choreography.
|
|
55
|
+
signal — prefer under-routing (answer plainly) over dragging a question through choreography.
|
|
56
56
|
|
|
57
57
|
**Zero-command principle (owner rule, 2026-07-12):** every rafa command — CLI verbs,
|
|
58
58
|
MCP tools, checkpoints, pushes, decisions logging — is AGENT-INTERNAL machinery. The
|
|
59
59
|
dev speaks intent; YOU run the machinery. Never instruct the dev to run a command you
|
|
60
60
|
can run yourself. The only human acts: init (provision) · `npx rafa pull` (once per
|
|
61
|
-
clone) · ci-setup approval · npm publish. **Toolbox is a recall surface:** at
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"unreported" when unknown, never guessed.
|
|
61
|
+
clone) · ci-setup approval · npm publish. **Toolbox is a recall surface:** at bootstrap,
|
|
62
|
+
load the committed toolbox (`.claude/skills/`, `.mcp.json`, commands) alongside brain
|
|
63
|
+
status; pass the matching slice into every atlas/bloom spawn prompt — agents USE the fit
|
|
64
|
+
capability instead of hand-rolling (only what's installed, never guessed; personal
|
|
65
|
+
`~/.claude/` stays live-recommend-only). **Actor envelope:** stamp `actorMeta {model,
|
|
66
|
+
agent, runner: "session"}` on every state-plane write (checkpoints, plan pushes,
|
|
67
|
+
decisions, reports) and export `RAFA_ACTOR_MODEL` before CLI calls — the platform records
|
|
68
|
+
WHO/WHAT executed; "unreported" when unknown, never guessed.
|
|
70
69
|
|
|
71
70
|
**Scope discipline (owner rule):** deliver exactly what the message asked — fix what
|
|
72
71
|
they're expecting, nothing else. No unsolicited extras beyond bloom's single opt-in
|
|
73
|
-
nudge. Fix-shaped prompts: recall the failure domain's knowledge → fix the asked
|
|
74
|
-
|
|
72
|
+
nudge. Fix-shaped prompts: recall the failure domain's knowledge → fix the asked thing
|
|
73
|
+
→ verify → stop.
|
|
75
74
|
|
|
76
75
|
## Offers — ask at the boundary, never nag
|
|
77
76
|
|
|
@@ -89,315 +88,196 @@ Three interaction modes by the weight of the action:
|
|
|
89
88
|
- session start, local ahead of platform → *"brain is N commits behind — push?"*
|
|
90
89
|
- reconciliation pending → *"branch <x> merged with N working-set files — distill now?"*
|
|
91
90
|
- adjudication pending → *"1 file diverged at the <x>→<y> fold — pick a copy?"*
|
|
92
|
-
- staleness (the M5 dirty queue,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
- staleness (the M5 dirty queue, from the SessionStart digest or `rafa dirty --json` at
|
|
92
|
+
boundaries) → *"N notes cite files you've touched — refresh just those?"* — accepted =
|
|
93
|
+
atlas scoped-refresh (only the citing notes, gates as usual, checkpoint/push per branch
|
|
94
|
+
rules), then `rafa dirty --consume`. Past the drift threshold the offer escalates to
|
|
95
|
+
*/rafa scan --brain-only* (the fire-alarm).
|
|
96
|
+
- open knowledge gaps (unanswered served-brain questions in the gaps store, pulled at
|
|
97
|
+
session start via `get_knowledge_gaps({repo, status: "open"})` → `{gaps: [{q, misses,
|
|
98
|
+
lastAt}]}`) → *"N open knowledge gaps — want me to close any?"* — accepted = atlas
|
|
99
|
+
scoped gap-authoring, routed EXACTLY like the staleness refresh (RECALL the domain,
|
|
100
|
+
author the closing note THROUGH THE NORMAL GATES — working set + `rafa checkpoint` on a
|
|
101
|
+
branch; verify-citations · compile · push on main), then `set_gap_status({repo, q,
|
|
102
|
+
status: "closed", note})` on the banked note, or `status: "out-of-scope"` when judged
|
|
103
|
+
not-our-knowledge (a classification, not a bank). Demand signal, not a blocker — ranks
|
|
104
|
+
BELOW staleness in the digest. (Automated CI gap-authoring is a KNOWN NEXT STEP, deferred.)
|
|
97
105
|
- user brain EMPTY (first session / founding scan just completed) → *"want me to
|
|
98
106
|
bootstrap your insights from your usage report? (compass distills it; every
|
|
99
107
|
candidate is offered — nothing banked without your yes)"* — accepted = run
|
|
100
108
|
`## insights`. Offered ONCE; a "no" is a standing no until the dev asks.
|
|
101
109
|
|
|
102
|
-
Offer etiquette (hard rules)
|
|
110
|
+
**Offer etiquette (hard rules):** boundaries only, never mid-flow · once per moment — a
|
|
103
111
|
"no" is remembered for the session and never re-argued · an unanswered offer never
|
|
104
|
-
blocks; keep working, the offer stands · admin verbs stay explicit — an ACCEPTED
|
|
105
|
-
|
|
112
|
+
blocks; keep working, the offer stands · admin verbs stay explicit — an ACCEPTED offer
|
|
113
|
+
IS the explicit invocation.
|
|
106
114
|
|
|
107
115
|
**Bootstrap digest — one question, however much is pending.** Session start may
|
|
108
116
|
accumulate many offers (staleness push, N distills, needs-adjudication flags, dirty
|
|
109
|
-
notes to refresh, a nudge). NEVER ask
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
117
|
+
notes to refresh, N open knowledge gaps via `get_knowledge_gaps`, a nudge). NEVER ask
|
|
118
|
+
them serially — batch into ONE itemized digest:
|
|
119
|
+
*"5 things pending: brain push · 2 merged branches to distill · 1 file needs
|
|
120
|
+
adjudication · 3 notes cite code you changed · 2 open knowledge gaps — want any now,
|
|
121
|
+
or later?"*
|
|
122
|
+
Dismissible as a unit; offer fatigue trains reflexive yes, which corrodes every consent
|
|
123
|
+
rung above it. Open gaps are one more line in this ONE digest — a pullable source, never
|
|
124
|
+
a serial prompt and never mid-flow.
|
|
125
|
+
|
|
126
|
+
**The M5 sensors feed you — you never poll.** Four deterministic instruments run outside
|
|
127
|
+
the model (blueprint hooks + the git boundary): the SessionStart digest injects
|
|
128
|
+
staleness/conflicts/corrections/active-plan at session start · every Edit/Write is
|
|
129
|
+
dirty-marked into `.rafa/dirty.jsonl` the moment it happens · `git push` runs
|
|
130
|
+
`rafa checkpoint` mechanically (non-blocking) · a correction-shaped prompt is queued to
|
|
131
|
+
`.rafa/reflex.jsonl` AND arrives with a `[rafa · reflex <id>]` steering injection. Your
|
|
132
|
+
part is the JUDGMENT half: consume `rafa dirty --json` at natural boundaries, offer the
|
|
133
|
+
scoped refresh (above), and run `rafa dirty --consume` ONLY after a refresh actually
|
|
134
|
+
shipped through the gates. Sensors make the moments deterministic; authoring stays yours.
|
|
135
|
+
|
|
136
|
+
**Guidance is ambient · front-loaded · earned — never interleaved.** The dev sees the
|
|
137
|
+
loop three ways and ONLY three: the **statusline** (always-on one-liner — plan progress ·
|
|
138
|
+
stale · corrections · conflicts; `rafa status --line` is the same truth for any surface) ·
|
|
139
|
+
the digest's **`[rafa · next] suggested next:`** line (deterministic, ranked: conflicts →
|
|
140
|
+
corrections → resume plan → staleness → open knowledge gaps — gaps the lowest rung, demand
|
|
141
|
+
signal not a blocker; honor it by putting that item FIRST in the bootstrap digest) · the
|
|
142
|
+
**boundary offers**. Never emit mid-flow "next step" reminders; the statusline already says
|
|
143
|
+
it silently.
|
|
133
144
|
|
|
134
145
|
**The correction reflex (bank it THIS session, not next scan).** When the
|
|
135
|
-
`[rafa · reflex <id>]` injection arrives: first address the dev's correction; then
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
`
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
## `init` — first run: found the stores + the full pass
|
|
164
|
-
1. Ensure structure (idempotent): `.rafa/active.md` = `# No active plan`.
|
|
165
|
-
2. Run the **full scan** (below) — build + validate the brain, improve, then offer to push.
|
|
166
|
-
|
|
167
|
-
## `scan` — the full pass (know → verify → improve → push)
|
|
168
|
-
The default runs the whole pipeline. `--brain-only` stops after the brain is validated (skips
|
|
169
|
-
improve + push — a cheap knowledge refresh).
|
|
170
|
-
|
|
171
|
-
1. **Scan — spawn `atlas`** context-isolated: *"Run the scan per `.claude/skills/rafa-scan/SKILL.md`:
|
|
172
|
-
comprehensive, breadth-before-depth, cited notes → `.rafa/brain/{rules,playbooks}/` +
|
|
173
|
-
`coverage.md`. Run `npx @rafinery/cli verify-citations` until it **exits 0**. Return a
|
|
174
|
-
coverage summary only — not the raw reads."*
|
|
175
|
-
2. **Gate 1 — checker (trust-but-verify)**: re-run `npx @rafinery/cli verify-citations`
|
|
176
|
-
yourself. Must **exit 0** (if not, re-spawn atlas to fix). It writes `citation-check.md`.
|
|
177
|
-
3. **Gate 2 — prism**: spawn the `prism` subagent **context-isolated** — pass ONLY:
|
|
178
|
-
*"Validate the scan in `.rafa/brain/` against the repo per your SOP; write
|
|
179
|
-
`.rafa/brain/checklist.md`."* Never pass atlas's reasoning — prism judges blind.
|
|
180
|
-
4. **Read** `.rafa/brain/checklist.md`. Append this round to `.rafa/brain/log.md`.
|
|
181
|
-
5. **`verdict: PASS`** → continue to Improve. **`ITERATE`** → **spawn `atlas`**: *"Fix every
|
|
182
|
-
blocker + major per `checklist.md`, re-run the checker to exit 0, return what changed."* Then
|
|
183
|
-
back to step 2. **Max 3 rounds**; if still not PASS, **STOP** — surface the findings and do
|
|
184
|
-
**not** improve or push (never improve/push an unvalidated brain).
|
|
185
|
-
6. **Improve** *(skip if `--brain-only`)* — run the **improve pass** (below): spawn `bloom` →
|
|
186
|
-
`.rafa/improve/`. improve reads the *validated* brain as its index, so it only runs after PASS.
|
|
187
|
-
7. **Push** — present the full summary (brain verdict/score + top improvements). **On the dev's
|
|
188
|
-
explicit approval**, push the brain: `npx @rafinery/cli push` — commits `.rafa/` and
|
|
189
|
-
pushes to the brain remote using the dev's own git auth, stamped `brain-for: <code sha>`.
|
|
190
|
-
Never push without approval.
|
|
191
|
-
8. **The coach offer (founding scan only)** — if this was the repo's FIRST scan and the
|
|
192
|
-
dev's user brain is empty (`list_dev_insights` → none), offer ONCE: *"the code side
|
|
193
|
-
is mapped — want me to bootstrap YOUR insights from your usage report?"* Accepted =
|
|
194
|
-
run `## insights` (compass; every candidate offered, banked only on yes). This is
|
|
195
|
-
the offer rung of the consent ladder — never auto-run, never re-asked after a no.
|
|
196
|
-
|
|
197
|
-
atlas scans + fixes; prism judges; bloom improves; you orchestrate + push on approval. You own
|
|
198
|
-
`log.md`; never edit `checklist.md` or the brain yourself — spawn atlas for that.
|
|
199
|
-
|
|
200
|
-
## `improve` — the improvement pass (rafa's 2nd mission; also step 6 above)
|
|
201
|
-
Requires the brain (#1). **Spawn the `bloom` subagent** context-isolated: *"Run your improvement
|
|
202
|
-
pass per your SOP — read the brain as index, multi-lens pass weighting the silent issues, delegate
|
|
203
|
-
security to real tools, write cited/prioritized improvements to `.rafa/improve/improvements/`,
|
|
204
|
-
cite-check them (`--root=.rafa/improve --dirs=improvements`, drop unresolved), regenerate
|
|
205
|
-
`ledger.md` + debt trend."* When it returns, read `ledger.md` and **surface only the top few
|
|
206
|
-
high-leverage P0/P1s — don't nag; the dev triages.**
|
|
207
|
-
|
|
208
|
-
## `plan <intent>` — brain-grounded, prism-validated decomposition
|
|
209
|
-
Per [the rafa-plan skill](../skills/rafa-plan/SKILL.md). The trio at plan time —
|
|
210
|
-
atlas drafts, bloom pulls, prism validates the plan itself:
|
|
211
|
-
1. **Staleness check** — if this repo is platform-connected, compare the MCP envelope's
|
|
212
|
-
`brainForSha` to the local brain stamp; if the platform is behind, surface "run `rafa push`"
|
|
213
|
-
(never proceed silently, never block).
|
|
214
|
-
2. **Spawn `atlas`** context-isolated: *"Draft a plan for `<intent>` per
|
|
215
|
-
`.claude/skills/rafa-plan/SKILL.md`: RECALL the brain slice for the touched domains (coverage →
|
|
216
|
-
search → rules/playbooks, honor non-exemplars), name the blast radius, decompose into
|
|
217
|
-
contract §7 files — one parent + child-owned tasks, globally-unique prefixed ids, each child
|
|
218
|
-
body carrying a `## Done-check`. Return the draft file contents."*
|
|
219
|
-
3. **Spawn `bloom`**: *"List open improvements in the blast radius `<domains>`; return the
|
|
220
|
-
top-leverage few as optional child tasks."* Fold them in, marked optional.
|
|
221
|
-
4. **Spawn `prism`** context-isolated: *"Validate this DRAFT plan against the brain + code per
|
|
222
|
-
`.claude/skills/rafa-plan/SKILL.md`: every task grounded (not hallucinated), every child has a
|
|
223
|
-
`## Done-check`. REJECT with reasons or PASS."* Fix-and-revalidate until PASS (max 3; then
|
|
224
|
-
surface and stop).
|
|
225
|
-
5. **Approval gate** (ExitPlanMode / the dev). On approval: write `plans/<plan>/*.md`, set
|
|
226
|
-
`active.md` = `# <plan-id>`, run `npx @rafinery/cli compile` to exit 0, then in a
|
|
227
|
-
connected repo **`push_plan` + `set_active_plan` immediately — approval IS the push
|
|
228
|
-
trigger for plans** (the dedicated plans channel; plans never ride the brain manifest;
|
|
229
|
-
no second prompt — the dev just approved this exact content). The plan renders on the
|
|
230
|
-
platform and becomes resumable from any session/machine/teammate within moments:
|
|
231
|
-
*"list plans"* = names only · *"load plan X"* materializes it back into `.rafa/plans/`.
|
|
232
|
-
|
|
233
|
-
## `build` — execute the active plan, trio-choreographed
|
|
234
|
-
Per [the rafa-build skill](../skills/rafa-build/SKILL.md). Resume from `active.md`
|
|
235
|
-
(or the platform's `get_active_plan` when connected — "load plan X" materializes it) —
|
|
236
|
-
never re-derive context.
|
|
237
|
-
Per item (work the tree in `blocked_by` order — an item with an unmet dependency is
|
|
238
|
-
DERIVED-blocked and waits): **atlas** recalls + implements → **prism** validates against
|
|
239
|
-
the item's `## Done-check` (**`status: done` only on prism PASS**; FAIL → atlas corrects)
|
|
240
|
-
→ **bloom** sweeps (new opportunities → ledger files; fixed-in-passing → `status: fixed`;
|
|
241
|
-
one opt-in nudge max) → update the item file's `status` + `## Log` + `## Decisions` →
|
|
242
|
-
at CHECKPOINTS (task done · cadence under session consent):
|
|
243
|
-
`push_plan`/`update_plan_status`/`log_decision` (plans channel — decisions record what
|
|
244
|
-
the DEV chose and why; paraphrase + pivotal quotes) + `rafa checkpoint` (working set)
|
|
245
|
-
so the platform reflects live progress. Terminal
|
|
246
|
-
statuses when honest: `superseded` (replaced by a newer plan) · `abandoned` (dropped).
|
|
247
|
-
If execution invalidates/creates brain knowledge, route per §capture (working set on a
|
|
248
|
-
branch; full `## scan` on main — never hand-edit main's brain around the gate). When all
|
|
249
|
-
children are done: prism-style final verify, set `active.md` = `# No active plan`,
|
|
250
|
-
final `push_plan` + `set_active_plan` (clear).
|
|
146
|
+
`[rafa · reflex <id>]` injection arrives: first address the dev's correction; then judge
|
|
147
|
+
it — DURABLE repo knowledge (a convention/contract/fact a future session needs) or a
|
|
148
|
+
one-off steer? Durable → bank NOW through the gates: on a branch, author/edit the note
|
|
149
|
+
under `.rafa/brain/**` (≥1 resolving cite) + `rafa checkpoint`; on main, full gates
|
|
150
|
+
(verify-citations · compile · push). Confirm to the dev in ONE line (note id + where it
|
|
151
|
+
landed), then `rafa reflex --consume <id>`. Not durable → say it stays session-only and
|
|
152
|
+
consume with verdict `session-only`. At the consume moment — the reflex's OWN checkpoint
|
|
153
|
+
beat, never a session-end sweep — emit **`report_loop_event(category: "reflex-outcome",
|
|
154
|
+
outcome: durable|session-only, subject: <reflex id>)`** so sage sees which corrections
|
|
155
|
+
became repo knowledge (shapes only: the verdict + the reflex id, never the correction
|
|
156
|
+
text). An ungroundable claim is NEVER banked (no cite = no note — tell the dev honestly).
|
|
157
|
+
Unprocessed corrections from abandoned sessions surface in the bootstrap digest. Dev-level
|
|
158
|
+
preferences route to compass's offer path (user brain), never the org stores. Raw
|
|
159
|
+
transcripts never enter any shared store; only the distilled, cited note ships.
|
|
160
|
+
|
|
161
|
+
**The frame is CONSENT (owner, 2026-07-10).** Four rungs, each action needs exactly one:
|
|
162
|
+
(1) **implied** — the message itself consents to what it asks, and only that · (2)
|
|
163
|
+
**session** — asked once, remembered, revocable mid-session ("stop pushing") · (3)
|
|
164
|
+
**boundary** — the offer; acceptance is the consent · (4) **standing** — durable opt-ins
|
|
165
|
+
recorded in config (insights capture per dev). And one thing consent can never waive:
|
|
166
|
+
nothing person-scoped leaves the user brain, ever.
|
|
167
|
+
|
|
168
|
+
**Subagent orchestration.** You orchestrate context-isolated *leaf* subagents — **atlas**
|
|
169
|
+
(scan/fix/build) · **prism** (validate) · **bloom** (improve) · **compass** (insights) ·
|
|
170
|
+
**sage** (observer) — shuttling artifacts via the filesystem. Subagents never spawn each
|
|
171
|
+
other (Claude Code forbids nesting), so the loop lives HERE. **Keep the heavy work inside
|
|
172
|
+
the subagents** — spawn atlas to read the whole codebase in *its* window; you hold only
|
|
173
|
+
summaries + on-disk artifacts (`.rafa/brain/`, `checklist.md`, `log.md`, `.rafa/improve/`).
|
|
251
174
|
|
|
252
175
|
## capture — during ANY work (plan/build/answering), consent-gated
|
|
176
|
+
|
|
253
177
|
Two destinations, one rule — route by what the observation is ABOUT:
|
|
254
|
-
- **About the code** (a fact/gotcha/how-to discovered while working) → the
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
## `help` (also: no argument, or an unrecognized command)
|
|
346
|
-
Print this reference verbatim and stop.
|
|
347
|
-
|
|
348
|
-
**End to end — from zero to a queryable, working brain:**
|
|
349
|
-
|
|
350
|
-
1. **Platform** — sign in → add a GitHub token → add brain repo + code repo → connect →
|
|
351
|
-
*Generate setup command* (15-min URL carrying a one-time MCP agent key).
|
|
352
|
-
2. **Install** — in the code repo: `npx @rafinery/cli init '<setup-url>'` — vendors the
|
|
353
|
-
blueprint (agents · /rafa · skills · contract), records the brain remote in the
|
|
354
|
-
committed `rafa.json` (teammates: clone → `npx rafa pull` just works), registers the
|
|
355
|
-
knowledge MCP in `.mcp.json` (secret-free) + puts the key in
|
|
356
|
-
`.claude/settings.local.json` (gitignored).
|
|
357
|
-
3. **Scan** — restart Claude Code → `/rafa scan` (atlas maps → prism validates → bloom
|
|
358
|
-
ledgers) → `rafa push` → webhook → the platform ingests the manifest.
|
|
359
|
-
4. **See it** — platform repo pages: Overview · Brain · Improvements · Plans; *Agent
|
|
360
|
-
access* mints keys for more MCP clients (Slack, incident.io, CI).
|
|
361
|
-
5. **Work** — `/rafa plan "<intent>"` (prism-validated, brain-grounded) → `/rafa build`
|
|
362
|
-
(atlas executes, prism gates each Done-check, bloom sweeps); every push syncs
|
|
363
|
-
progress so any session/teammate resumes exactly where work stopped.
|
|
364
|
-
6. **Query** — any MCP client with a key reads the brain at `<platform>/api/mcp`:
|
|
365
|
-
`get_brain_status` · `search_knowledge` · `get_rule/playbook/improvement` ·
|
|
366
|
-
`get_plan` · `get_active_plan`. Read-only, cited, per-repo scoped.
|
|
367
|
-
|
|
368
|
-
**rafa has two surfaces.** `/rafa <cmd>` runs the intelligent, in-editor passes; the terminal
|
|
369
|
-
`rafa` CLI (run via `npx @rafinery/cli@latest <cmd>`) does the deterministic plumbing. Several
|
|
370
|
-
names exist on both — the CLI does the mechanical half, `/rafa` the intelligent half.
|
|
371
|
-
|
|
372
|
-
**`/rafa` — in the editor (LLM does the work):**
|
|
373
|
-
| Command | What it does |
|
|
374
|
-
|---|---|
|
|
375
|
-
| `/rafa init` | First run: ensure structure, then run the full scan pass. |
|
|
376
|
-
| `/rafa scan [--brain-only]` | The full pass: know → verify → improve → push. `--brain-only` stops after the brain is validated (a cheap knowledge refresh). |
|
|
377
|
-
| `/rafa improve` | The improvement pass — bloom writes a cited, prioritized (P0–P3) ledger. |
|
|
378
|
-
| `/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. |
|
|
379
|
-
| `/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. |
|
|
380
|
-
| `/rafa push` | (Re-)push the brain to the brain remote (your git auth). |
|
|
381
|
-
| `/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. |
|
|
382
|
-
| `/rafa insights` | compass bootstraps/refreshes your private user brain from your native usage report + recent sessions — every insight offered before it's banked. |
|
|
383
|
-
| `/rafa leverage` | Tune your toolbox: reason over config and, on approval, apply fixes exactly — merge settings, wire an MCP, scaffold a skill. |
|
|
384
|
-
| `/rafa migrate` | Semantic migration — rewrite plans to a new schema preserving meaning, then compile-gate. |
|
|
385
|
-
| `/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). |
|
|
386
|
-
|
|
387
|
-
**`rafa` — in the terminal (`npx @rafinery/cli@latest <cmd>`; deterministic):**
|
|
388
|
-
| Command | What it does |
|
|
178
|
+
- **About the code** (a fact/gotcha/how-to discovered while working) → the branch
|
|
179
|
+
**working set**: author or edit the brain-shaped FILE under `.rafa/brain/{rules,
|
|
180
|
+
playbooks}/` (files are the working medium; hydrate the existing note first via
|
|
181
|
+
`rafa hydrate <rule|playbook> <id>` when refining one). Candidate-grade — no gate at
|
|
182
|
+
capture; it enters the org brain only at merge-to-main distillation. Announce per file
|
|
183
|
+
as it happens (*"capturing: <path>"* — a "no" drops it). Sync at **checkpoints**
|
|
184
|
+
(`rafa checkpoint`): task done · plan approved · explicit ask · cadence under session
|
|
185
|
+
consent · git push/pull of the code branch — **never session-end**. A checkpoint
|
|
186
|
+
CONFLICT (a teammate's newer copy) is decided HERE, this session — read the `.theirs.md`
|
|
187
|
+
copy, merge/adopt/keep, re-checkpoint. **Third-party rule:** a statement attributable to
|
|
188
|
+
someone not in this session ("Carol says…") is NEVER captured verbatim — paraphrase to an
|
|
189
|
+
ownerless code fact, or drop it. **No person-scoped content in the working set, ever** — a
|
|
190
|
+
note that names a person is rewritten person-free or routed/dropped. **No secrets** —
|
|
191
|
+
names are contracts, values are secrets (the platform also screens; don't rely on it).
|
|
192
|
+
- **About the dev** (a repeated correction, a stated preference/constraint) → offer first
|
|
193
|
+
(*"want me to remember that?"*), then `put_dev_insight` — the dev's PRIVATE user brain,
|
|
194
|
+
cross-repo. Never logged to repo activity, never narrated to anyone (consent floor:
|
|
195
|
+
nothing person-scoped leaves it).
|
|
196
|
+
|
|
197
|
+
## Verb map — one line each; the procedure lives in the linked skill
|
|
198
|
+
|
|
199
|
+
Each work/admin verb dispatches to its SOP. Read the skill only when the verb runs; it is
|
|
200
|
+
self-contained and ADR-shaped. **You orchestrate + push on approval; the subagent follows
|
|
201
|
+
its skill verbatim.** Admin verbs (init · scan · push · migrate · update) run ONLY when
|
|
202
|
+
explicitly typed; an ACCEPTED boundary offer counts as the explicit invocation.
|
|
203
|
+
|
|
204
|
+
| Verb | One-line route | SOP |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| `plan <intent>` | trio decomposition — atlas drafts brain-grounded contract §7 files (Done-checks), bloom pulls blast-radius improvements, prism validates the plan; approval → compile → `push_plan` + `set_active_plan` | [rafa-plan](../skills/rafa-plan/SKILL.md) |
|
|
207
|
+
| `build` | execute the active plan per item (in `blocked_by` order): atlas recalls+implements → prism gates `status: done` on the `## Done-check` → bloom sweeps the ledger → update file + journals → checkpoint (push_plan/log_decision/`rafa checkpoint`); final verify + clear `active.md` when all children done | [rafa-build](../skills/rafa-build/SKILL.md) |
|
|
208
|
+
| `improve` | spawn bloom → cited, prioritized P0–P3 ledger in `.rafa/improve/`; surface only the top few high-leverage items, never nag | [rafa-improve](../skills/rafa-improve/SKILL.md) |
|
|
209
|
+
| `scan [--brain-only]` | the full pass know → verify → improve → push — atlas maps → gate-1 checker → prism validates → iterate (max 3) → improve → push on approval → founding-scan coach offer. `--brain-only` stops after validation. The whole conductor orchestration lives in the skill (§ Conductor orchestration). | [rafa-scan](../skills/rafa-scan/SKILL.md) |
|
|
210
|
+
| `init` | first run: ensure `.rafa/active.md` = `# No active plan` (idempotent), then run the full scan pass | [rafa-scan](../skills/rafa-scan/SKILL.md) |
|
|
211
|
+
| `distill [<branch>]` | reconcile a merged branch's working set into the org brain — prism validates each file vs merged MAIN, atlas authors survivors through verify-citations · compile · push, refutes with cites, flags `needs-adjudication`. Offer-driven at bootstrap; CI runs it headlessly. | [rafa-distill](../skills/rafa-distill/SKILL.md) |
|
|
212
|
+
| `insights` | spawn compass → bootstrap/refresh the dev's private user brain from their native `/insights` report + recent work; every candidate OFFERED, banked only on yes (`put_dev_insight`). Capture during normal work is §capture's job, not this command. | [rafa-insights](../skills/rafa-insights/SKILL.md) |
|
|
213
|
+
| `leverage` | reason over the committed toolbox (`.claude/settings.json`, `.mcp.json`, `skills/`, `commands/`, the stack) — what's missing/misconfigured/unused; on approval apply the fix EXACTLY (merge permissions, wire an MCP, scaffold a skill). Merge, never clobber; show the diff. The CLI reports, you fix. | [rafa-leverage](../skills/rafa-leverage/SKILL.md) |
|
|
214
|
+
| `sage` | explicit OVERRIDE of the implicit observer pass (below) | [rafa-sage](../skills/rafa-sage/SKILL.md) |
|
|
215
|
+
| `push` | `npx @rafinery/cli push` — commit `.rafa/` and push to the brain remote (the dev's own git auth), stamped `brain-for: <code sha>`. After a scan, or to re-sync a changed brain. Never without approval. | — |
|
|
216
|
+
| `migrate` · `update` | brain-side schema migration — see below | — |
|
|
217
|
+
| `help` (also no arg / unrecognized) | print this reference verbatim, then stop | — |
|
|
218
|
+
|
|
219
|
+
## sage — the silent L5 observer (runs IMPLICITLY, zero-command; owner 2026-07-13)
|
|
220
|
+
|
|
221
|
+
Devs never type `/rafa sage`. **Trigger:** at completion boundaries — build final-verify ·
|
|
222
|
+
distill close · bootstrap — when new loop events exist since the learnings ledger's newest
|
|
223
|
+
entry, spawn sage per [rafa-sage](../skills/rafa-sage/SKILL.md); announce ONE line, proceed;
|
|
224
|
+
its proposals ride the NEXT bootstrap digest. Writing proposals is the just-do rung; the
|
|
225
|
+
consent moment is ACCEPTING one (accepted = a versioned, MR-reviewed card/SOP edit — proposals
|
|
226
|
+
never self-apply). `/rafa sage` is the explicit override. Full mechanics (≥10-event threshold,
|
|
227
|
+
`get_loop_events` shape read, scrub step, ledger schema, the person-free/asset-free creed) live
|
|
228
|
+
in the skill.
|
|
229
|
+
|
|
230
|
+
## migrate · update — brain-side schema migration (no skill; the intelligence-only half)
|
|
231
|
+
|
|
232
|
+
The terminal CLI already did the mechanical/blueprint half; `/rafa` does the part that needs
|
|
233
|
+
intelligence. Run `npx @rafinery/cli compile` to exit 0 after either; never hand-edit around
|
|
234
|
+
a migration or discard tuned files.
|
|
235
|
+
- **`migrate`** — semantic plan-shape changes (a plan's *shape* changed; each file must be
|
|
236
|
+
understood to be rewritten). Read the target schema in [`.claude/rafa/contract.md`](../rafa/contract.md)
|
|
237
|
+
(§6/§7 for plans) + the `from` versions in `rafa.json`; rewrite each affected file under
|
|
238
|
+
`.rafa/plans/` (and any structured dir) preserving meaning — remap fields, fill new required
|
|
239
|
+
fields sensibly; compile to exit 0; surface the diff for approval; offer `rafa push` if
|
|
240
|
+
connected. (Mechanical field-rename/path-move runs via the terminal `rafa migrate`.)
|
|
241
|
+
- **`update`** — the BRAIN-side of an upgrade, AFTER `npx @rafinery/cli@latest update` synced
|
|
242
|
+
the blueprint + ran mechanical migrations (don't re-run the CLI here). Compare
|
|
243
|
+
`.rafa/manifest.json`'s `schemaVersion` (+ `rafa.json`'s `contract`/`plans`) to the current
|
|
244
|
+
contract — that gap is what the CLI flagged. **Contract bumped → the brain is a stale cache:**
|
|
245
|
+
re-scan (`## scan`) to regenerate, or intelligently rewrite the affected notes + re-validate.
|
|
246
|
+
**Plans shape changed:** rewrite each per `migrate`. Then compile to exit 0, advance the data
|
|
247
|
+
version in `rafa.json` (`contract`/`plans` → the versions you migrated to), summarize; offer
|
|
248
|
+
`rafa push` if connected. (If the CLI update hasn't run, tell the dev to run it first.)
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
**End to end — zero to a queryable brain:** platform (sign in → GitHub token → add brain +
|
|
253
|
+
code repos → connect → *Generate setup command*, a 15-min URL with a one-time MCP key) →
|
|
254
|
+
install (`npx @rafinery/cli init '<setup-url>'` vendors the blueprint + records the brain
|
|
255
|
+
remote in committed `rafa.json` + registers the MCP in `.mcp.json`, key in gitignored
|
|
256
|
+
`.claude/settings.local.json`) → `/rafa scan` → `rafa push` → webhook ingests the manifest →
|
|
257
|
+
repo pages (Overview · Brain · Improvements · Plans; *Agent access* mints more MCP keys) →
|
|
258
|
+
`/rafa plan` → `/rafa build` (every push syncs progress; any session/teammate resumes exactly
|
|
259
|
+
where work stopped) → query: any MCP client reads `<platform>/api/mcp` (`get_brain_status` ·
|
|
260
|
+
`search_knowledge` · `get_rule/playbook/improvement` · `get_plan` · `get_active_plan` —
|
|
261
|
+
read-only, cited, per-repo scoped).
|
|
262
|
+
|
|
263
|
+
**rafa has two surfaces.** `/rafa <cmd>` runs the intelligent in-editor passes (the verb map
|
|
264
|
+
above); the terminal `rafa` CLI (`npx @rafinery/cli@latest <cmd>`) does the deterministic
|
|
265
|
+
plumbing. Several names exist on both — the CLI does the mechanical half, `/rafa` the
|
|
266
|
+
intelligent half. The deterministic surface:
|
|
267
|
+
|
|
268
|
+
| `rafa` (terminal) | What it does |
|
|
389
269
|
|---|---|
|
|
390
|
-
| `init [<setup-url>]` | Vendor the blueprint into the repo
|
|
391
|
-
| `update [--overwrite\|--keep]` | Blueprint-side of an upgrade: re-sync
|
|
392
|
-
| `compile` |
|
|
270
|
+
| `init [<setup-url>]` | Vendor the blueprint into the repo + wire the platform from a setup URL. `.rafa/` stays lazy. |
|
|
271
|
+
| `update [--overwrite\|--keep]` | Blueprint-side of an upgrade: re-sync (asks before overwriting tuned files), run mechanical migrations, report what the brain needs. |
|
|
272
|
+
| `compile` | Contract gate → `.rafa/manifest.json`. |
|
|
393
273
|
| `verify-citations` | Deterministic citation checker (B1 resolution · B2 completeness · policy). |
|
|
394
274
|
| `push` | Compile, then push `.rafa/` to the brain remote (a main-branch act; stamps the contract copy). |
|
|
395
|
-
| `pull [--full] [--force]` |
|
|
396
|
-
| `leverage` | Detect toolbox gaps (deterministic)
|
|
275
|
+
| `pull [--full] [--force]` | Bootstrap the lazy `.rafa/` from committed `rafa.json`; `--full` mirrors the whole brain repo. Never re-scans existing knowledge. |
|
|
276
|
+
| `leverage` | Detect toolbox gaps (deterministic) + print prioritized tips — the detector for `/rafa leverage`. |
|
|
397
277
|
| `migrate` | Run the mechanical (deterministic) migrations. |
|
|
398
278
|
|
|
399
|
-
If the dev typed a **terminal-only** command (`compile`) as a
|
|
400
|
-
shell (`rafa compile`)
|
|
279
|
+
If the dev typed a **terminal-only** command (`compile`, `verify-citations`, `pull`) as a
|
|
280
|
+
slash command, point them to the shell (`rafa compile`) and stop.
|
|
401
281
|
|
|
402
282
|
---
|
|
403
283
|
Token discipline: glob/grep/AST before reading; scoped reads; deterministic extraction
|