ruvnet-brain 3.9.134-dev → 4.0.2

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 (218) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/README.md +5 -5
  3. package/bin/install.mjs +382 -36
  4. package/console/CONTRACT.md +172 -0
  5. package/console/activity.js +753 -0
  6. package/console/app.js +4189 -0
  7. package/console/architecture.html +1221 -0
  8. package/console/assets/depth-1.webp +0 -0
  9. package/console/assets/depth-2.webp +0 -0
  10. package/console/assets/depth-3.webp +0 -0
  11. package/console/assets/harness-vs-plain.svg +259 -0
  12. package/console/assets/hero.webp +0 -0
  13. package/console/assets/memory.webp +0 -0
  14. package/console/assets/metaharness.svg +247 -0
  15. package/console/index.html +777 -0
  16. package/console/install-architecture.html +162 -0
  17. package/console/install-mockup.html +543 -0
  18. package/console/style.css +2144 -0
  19. package/console/tips.css +926 -0
  20. package/console/tips.html +858 -0
  21. package/console/tips.js +128 -0
  22. package/docs/RELEASE-NOTES-4.0.md +88 -0
  23. package/kb/model-requirements.mjs +37 -6
  24. package/kb/zip-extract.mjs +53 -14
  25. package/keys/ruvnet-brain-signing.pub.pem +3 -0
  26. package/package.json +14 -22
  27. package/plugin/.claude-plugin/marketplace.json +14 -0
  28. package/plugin/.claude-plugin/plugin.json +22 -0
  29. package/plugin/.codex-plugin/plugin.json +21 -0
  30. package/plugin/.mcp.json +8 -0
  31. package/plugin/commands/brain-console.md +16 -0
  32. package/plugin/commands/configure.md +33 -0
  33. package/plugin/commands/rvbc.md +79 -0
  34. package/plugin/commands/rvcb.md +16 -0
  35. package/plugin/commands/whats-new.md +57 -0
  36. package/plugin/hooks/codex-hooks.json +160 -0
  37. package/plugin/hooks/hook-contracts.json +77 -0
  38. package/plugin/hooks/hooks.json +202 -0
  39. package/plugin/mcp/managed-cli-interface.mjs +47 -4
  40. package/plugin/mcp/server.mjs +56 -6
  41. package/plugin/scripts/anticipate.sh +534 -0
  42. package/plugin/scripts/codex-hook-adapter.mjs +96 -0
  43. package/plugin/scripts/continuation-gate.mjs +267 -0
  44. package/plugin/scripts/design-wall.sh +137 -0
  45. package/plugin/scripts/detach.mjs +182 -0
  46. package/plugin/scripts/first-session-worker.mjs +38 -0
  47. package/plugin/scripts/gate-receipt.sh +35 -0
  48. package/plugin/scripts/ground-before-write.sh +199 -0
  49. package/plugin/scripts/ground-ruvnet.sh +517 -0
  50. package/plugin/scripts/grounding-stamp.sh +113 -0
  51. package/plugin/scripts/grounding-substance.mjs +595 -0
  52. package/plugin/scripts/hijack-ruvnet.sh +81 -0
  53. package/plugin/scripts/hook-input.mjs +558 -0
  54. package/plugin/scripts/hook-shim-bash.mjs +55 -0
  55. package/plugin/scripts/hook-shim.mjs +303 -0
  56. package/plugin/scripts/host-update.mjs +58 -0
  57. package/plugin/scripts/kling-preflight.sh +146 -0
  58. package/plugin/scripts/learn-capture.sh +173 -0
  59. package/plugin/scripts/learn-flush.mjs +155 -0
  60. package/plugin/scripts/lesson-hooks.sh +213 -0
  61. package/plugin/scripts/md-stamp.mjs +219 -0
  62. package/plugin/scripts/protect-brain-state.sh +84 -0
  63. package/plugin/scripts/route-dispatch.sh +147 -0
  64. package/plugin/scripts/routing-outcome-capture.mjs +89 -0
  65. package/plugin/scripts/runtime-preferences.mjs +269 -0
  66. package/plugin/scripts/session-start-core.mjs +477 -0
  67. package/plugin/scripts/session-start.sh +13 -0
  68. package/plugin/scripts/signal-watch.mjs +193 -0
  69. package/plugin/scripts/unprompted-runtime.mjs +377 -0
  70. package/plugin/scripts/update-apply.mjs +419 -0
  71. package/plugin/scripts/verify-interface.sh +53 -0
  72. package/plugin/scripts/version-bump-gate.sh +112 -0
  73. package/plugin/skills/brain-build/SKILL.md +123 -0
  74. package/plugin/skills/brain-console/SKILL.md +22 -0
  75. package/plugin/skills/brain-prompt/SKILL.md +83 -0
  76. package/plugin/skills/brain-score/SKILL.md +101 -0
  77. package/plugin/skills/release-proof/SKILL.md +81 -0
  78. package/plugin/skills/release-proof/agents/openai.yaml +4 -0
  79. package/plugin/skills/release-proof/references/receipt-contract.md +38 -0
  80. package/plugin/skills/release-proof/scripts/release-proof.mjs +210 -0
  81. package/plugin/skills/ruvnet-brain/PLAYBOOK.md +121 -0
  82. package/plugin/skills/ruvnet-brain/SKILL.md +234 -0
  83. package/plugin/skills/rvbc/SKILL.md +23 -0
  84. package/plugin/skills/savings/SKILL.md +46 -0
  85. package/plugin/skills/whats-new/SKILL.md +22 -0
  86. package/scripts/adr-backfill.mjs +107 -0
  87. package/scripts/advocacy-outcomes.mjs +808 -0
  88. package/scripts/agentdb-context.mjs +216 -0
  89. package/scripts/agentdb-fleet-doctor.mjs +101 -0
  90. package/scripts/ascii-drift.mjs +236 -0
  91. package/scripts/behavioral-l1-l4.mjs +210 -0
  92. package/scripts/brain-capability-check.mjs +72 -0
  93. package/scripts/brain-grade-groundtruth.mjs +100 -0
  94. package/scripts/brain-latency-50.mjs +227 -0
  95. package/scripts/brain-novice-50.mjs +189 -0
  96. package/scripts/brain-stamp.mjs +94 -0
  97. package/scripts/brain-state.mjs +212 -0
  98. package/scripts/build-bundle.mjs +522 -0
  99. package/scripts/build-concepts.mjs +132 -0
  100. package/scripts/build-l2.mjs +71 -0
  101. package/scripts/build-primer.mjs +73 -0
  102. package/scripts/build-symbols.mjs +68 -0
  103. package/scripts/calibrate-router.mjs +97 -0
  104. package/scripts/capability-audit.mjs +321 -0
  105. package/scripts/capability-registry.mjs +876 -0
  106. package/scripts/check-indexation.mjs +108 -0
  107. package/scripts/check-legibility.mjs +189 -0
  108. package/scripts/ci/build-fixture-kb.mjs +67 -0
  109. package/scripts/ci/learning-replay-codex-adapter.mjs +62 -0
  110. package/scripts/ci/learning-replay-recorder.mjs +59 -0
  111. package/scripts/ci/mutate-hook-timeout.mjs +70 -0
  112. package/scripts/ci/stranger-fixture-stage.mjs +17 -0
  113. package/scripts/ci/stranger-scenario.mjs +228 -0
  114. package/scripts/ci/stranger-timeout.mjs +25 -0
  115. package/scripts/ci-verdict.mjs +29 -0
  116. package/scripts/claims-verify.mjs +710 -0
  117. package/scripts/clear-claude-tmp.sh +31 -0
  118. package/scripts/console-engine.mjs +434 -0
  119. package/scripts/console-engine.test.mjs +125 -0
  120. package/scripts/corpus-qa.mjs +250 -0
  121. package/scripts/correction-detect-embed.mjs +346 -0
  122. package/scripts/correction-detect-measure.mjs +270 -0
  123. package/scripts/correction-detect.mjs +686 -0
  124. package/scripts/count-chunks.mjs +54 -0
  125. package/scripts/described-questions.json +30 -0
  126. package/scripts/design-grade.mjs +58 -0
  127. package/scripts/dev-plugin-link.sh +105 -0
  128. package/scripts/distill-project.mjs +200 -0
  129. package/scripts/doc-currency.mjs +801 -0
  130. package/scripts/eval-brain.mjs +244 -0
  131. package/scripts/fix-metaharness-memretrieve.mjs +121 -0
  132. package/scripts/full-hints.mjs +87 -0
  133. package/scripts/gate.sh +39 -0
  134. package/scripts/gates.mjs +146 -0
  135. package/scripts/gen-console-images.mjs +54 -0
  136. package/scripts/gen-images.mjs +47 -0
  137. package/scripts/git-clone-refresh.mjs +52 -0
  138. package/scripts/git-hooks/pre-push +126 -0
  139. package/scripts/goal-match.mjs +398 -0
  140. package/scripts/goldie-research.mjs +223 -0
  141. package/scripts/goldie-weekly.sh +67 -0
  142. package/scripts/health-repair.mjs +250 -0
  143. package/scripts/helix-scenario-questions.json +10 -0
  144. package/scripts/ingest-gists.mjs +230 -0
  145. package/scripts/ingest-meeting.mjs +115 -0
  146. package/scripts/ingest-repo.mjs +79 -0
  147. package/scripts/install-npx-witness.sh +49 -0
  148. package/scripts/issue-fix.mjs +639 -0
  149. package/scripts/issue-watch.mjs +276 -0
  150. package/scripts/issue4-close-note.md +31 -0
  151. package/scripts/key-canary.mjs +91 -0
  152. package/scripts/latency-to-surface.mjs +233 -0
  153. package/scripts/learning-enable.mjs +380 -0
  154. package/scripts/learning-replay.mjs +1570 -0
  155. package/scripts/learnings.mjs +62 -0
  156. package/scripts/lesson-gate.mjs +680 -0
  157. package/scripts/lesson-lifecycle.mjs +449 -0
  158. package/scripts/lesson-promote.mjs +262 -0
  159. package/scripts/lesson-ratify.mjs +98 -0
  160. package/scripts/lesson-seed.mjs +252 -0
  161. package/scripts/lesson-store.mjs +447 -0
  162. package/scripts/loop-checkpoint.mjs +86 -0
  163. package/scripts/memdb-health.sh +14 -0
  164. package/scripts/memory-doctor.mjs +271 -0
  165. package/scripts/model-catalog.mjs +79 -0
  166. package/scripts/nightly-controller.mjs +66 -0
  167. package/scripts/nightly-gists.sh +72 -0
  168. package/scripts/nightly-wrapper.sh +180 -0
  169. package/scripts/notify.sh +12 -0
  170. package/scripts/npx-witness.sh +56 -0
  171. package/scripts/onboarding-console.mjs +2749 -0
  172. package/scripts/private-fence.mjs +69 -0
  173. package/scripts/proactivity-metrics.mjs +118 -0
  174. package/scripts/proof-questions.json +56 -0
  175. package/scripts/prove.mjs +95 -0
  176. package/scripts/proxy/claude-proxied.sh +57 -0
  177. package/scripts/proxy/proxy-revert.sh +59 -0
  178. package/scripts/proxy/proxy-up.sh +60 -0
  179. package/scripts/proxy/proxy-verify.mjs +142 -0
  180. package/scripts/published-surface-probe.mjs +241 -0
  181. package/scripts/qe/card-lane-gate.mjs +162 -0
  182. package/scripts/qe/session-start-gate.mjs +229 -0
  183. package/scripts/qe/ux-suite.mjs +323 -0
  184. package/scripts/reconcile-project.mjs +0 -0
  185. package/scripts/record-lesson.mjs +113 -0
  186. package/scripts/refresh-model-catalog.mjs +99 -0
  187. package/scripts/release-proof.mjs +9 -0
  188. package/scripts/release-vector.mjs +281 -0
  189. package/scripts/release.mjs +395 -0
  190. package/scripts/remedy-registry.mjs +247 -0
  191. package/scripts/rerank-cap-eval.mjs +265 -0
  192. package/scripts/rerank-cap-warm-ab.mjs +129 -0
  193. package/scripts/route-cheap.mjs +20 -15
  194. package/scripts/router-utilization.mjs +182 -0
  195. package/scripts/routing-flywheel.mjs +596 -0
  196. package/scripts/rvf-generation.mjs +104 -0
  197. package/scripts/rvf-index-audit.mjs +138 -0
  198. package/scripts/self-update.mjs +508 -0
  199. package/scripts/selfcheck.mjs +7 -1
  200. package/scripts/sign-bundle.mjs +69 -0
  201. package/scripts/signal-watch.mjs +171 -0
  202. package/scripts/stack-sync.mjs +469 -0
  203. package/scripts/stamp-existing-rvf-generations.mjs +53 -0
  204. package/scripts/stamp-sweep.mjs +144 -0
  205. package/scripts/status-honesty.mjs +102 -0
  206. package/scripts/sync-version.mjs +217 -0
  207. package/scripts/token-report.mjs +102 -0
  208. package/scripts/top100-benchmark.mjs +479 -0
  209. package/scripts/top100-corpus.mjs +112 -0
  210. package/scripts/top100-semantic-assertions.mjs +449 -0
  211. package/scripts/update-apply.mjs +9 -0
  212. package/scripts/upgrade-notice.mjs +14 -0
  213. package/scripts/verify-bundle.mjs +51 -0
  214. package/scripts/verify-channels.mjs +184 -0
  215. package/scripts/verify-model-catalog.mjs +104 -0
  216. package/scripts/verify-nightly-close-issue4.sh +31 -0
  217. package/scripts/version.mjs +40 -0
  218. package/scripts/wired-check.mjs +864 -0
@@ -0,0 +1,172 @@
1
+ # Onboarding Console — API + data contract (v1)
2
+
3
+ Updated: 2026-07-17
4
+ Created: 2026-07-15
5
+
6
+ The single source of truth both the backend (`scripts/onboarding-console.mjs`) and the
7
+ frontend (`console/index.html` + `app.js` + `style.css`) build against. Implements ADR-0013
8
+ and DDD-0002. **The ordering is the design: Mirror → Explain → Recommend → (consent) Apply → Undo.**
9
+
10
+ The server binds `127.0.0.1` only and mints a random `token` per launch. Every mutating request
11
+ must echo the token. The page receives the token inlined at render time (`window.__CONSOLE_TOKEN__`).
12
+ A GET with a wrong/absent token still serves read-only state; a POST with a wrong token is `403`.
13
+
14
+ ---
15
+
16
+ ## GET `/api/state` — fast sections (no network)
17
+
18
+ Returns in well under a second. `memory.fleet` is **`null` here by design** — scanning every memory
19
+ store on the machine costs ~90ms each and a real machine has 100+, which is far too slow to sit in
20
+ front of the page's first paint. The fleet arrives separately from `GET /api/memory`.
21
+
22
+ `GET /api/state?fast=1` replays the last good gather from disk (~3ms) so a repeat load paints
23
+ instantly, then the live call replaces it. The cached copy never contains `token` — that is minted
24
+ per server run and spliced in on read.
25
+
26
+ ```jsonc
27
+ {
28
+ "token": "…",
29
+ "generatedAt": "2026-07-14T…Z",
30
+ "host": { "user": "stuartkerr", "platform": "darwin", "node": "v22…", "npmPrefix": "~/.npm-global" },
31
+ "sections": {
32
+ "wiring": {
33
+ "summary": { "npx": 190, "global": 12, "mcp": 6, "plugin": 5, "projectsWithNpx": 16 },
34
+ "sites": [
35
+ { "scope": "project", "project": "ruvnet-brain", "file": ".claude/settings.json",
36
+ "event": "PreToolUse", "matcher": "Bash", "spec": "npx @claude-flow/cli@latest hooks …",
37
+ "mechanism": "NPX" }
38
+ ]
39
+ },
40
+ "memory": {
41
+ "fleet": [
42
+ { "name": "ruvnet-brain", "total": 1023, "embedded": 1021, "coverPct": 99.8,
43
+ "patterns": 456, "learns": true, "findings": [] }
44
+ ],
45
+ "health": {
46
+ "project": "ruvnet-brain", "score": 92, "summary": "learns; recall-quality not probed",
47
+ "dimensions": [
48
+ { "key": "liveness", "label": "Liveness", "status": "ok",
49
+ "detail": "store→search round-trip works on the live path", "deduction": 0 },
50
+ { "key": "coverage", "label": "Coverage", "status": "ok", "detail": "checkpoint present, <1d old", "deduction": 0 },
51
+ { "key": "recallQuality", "label": "Recall quality", "status": "notTested",
52
+ "detail": "no embedding round-trip run this session", "deduction": 0 },
53
+ { "key": "compactionSurvival", "label": "Compaction survival", "status": "ok",
54
+ "detail": "PreCompact snapshot present", "deduction": 0 },
55
+ { "key": "sessionSurfacing", "label": "Session surfacing", "status": "ok",
56
+ "detail": "SessionStart hook surfaces state", "deduction": 0 }
57
+ ],
58
+ "notTested": ["recallQuality"]
59
+ }
60
+ },
61
+ "savings": {
62
+ "totals": { "count": 3, "usdSaved": 0.42, "msSaved": 18400 }, // null ⇒ render "nothing measured yet"
63
+ "note": "receipts only — no modelled or projected savings",
64
+ "receipts": [
65
+ { "at": "2026-07-13T…Z", "capability": "model-routing", "task": "…",
66
+ "chosenTier": "haiku", "baselineTier": "opus", "measuredMs": 4200, "measuredUsd": 0.14 }
67
+ ]
68
+ },
69
+ "config": {
70
+ "path": "~/.claude/ruvnet-brain/config.json",
71
+ "exists": true,
72
+ "values": { "openrouterKey": true, "nightly": true, "routing": "auto", "qeFleet": false },
73
+ "schema": [
74
+ { "key": "openrouterKey", "label": "OpenRouter API key", "type": "secret",
75
+ "help": "Unlocks cheap-model routing + the self-improvement loop", "secret": true },
76
+ { "key": "nightly", "label": "Nightly brain refresh", "type": "bool",
77
+ "help": "Rebuild the KB from pinned SHAs overnight" },
78
+ { "key": "routing", "label": "Token-smart routing", "type": "enum",
79
+ "options": ["auto", "off"], "help": "Route cheap tasks to smaller models" },
80
+ { "key": "qeFleet", "label": "On-demand QE fleet", "type": "bool",
81
+ "help": "Agentic-QE test fleet, spun up on request" }
82
+ ]
83
+ },
84
+ "recommendations": [ /* Recommendation[] — non-stack, e.g. de-npx a project */ ]
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## GET `/api/memory` — the across-your-projects fleet scan (slow, ~7–10s)
90
+
91
+ ```jsonc
92
+ { "fleet": [ { "name": "ruvnet-brain", "total": 1023, "embedded": 1021, "coverPct": 99.8, … } ] }
93
+ ```
94
+
95
+ Split out of `/api/state` so it cannot block first paint. The page renders memory health immediately
96
+ and merges this list into the same card once it lands.
97
+
98
+ ## GET `/api/stack` — the network audit (slow, ~5–20s; page loads a skeleton first)
99
+
100
+ ```jsonc
101
+ {
102
+ "packages": [
103
+ { "name": "ruflo", "installed": "3.30.2", "target": "3.30.2", "tag": "alpha", "state": "CURRENT" }
104
+ // state ∈ CURRENT | BEHIND | AHEAD | BROKEN | UNRESOLVED
105
+ ],
106
+ "shadows": [
107
+ { "name": "@ruvector/rvf", "version": "0.1.9", "global": "0.2.3", "dir": "~/.npm/_npx/…", "stale": true }
108
+ ],
109
+ "summary": { "total": 40, "behind": 0, "broken": 1, "ahead": 0, "current": 38, "shadows": 15, "stale": 15 },
110
+ "recommendations": [ /* Recommendation[] — sync BEHIND, purge stale shadows */ ]
111
+ }
112
+ ```
113
+
114
+ ## Recommendation — the aggregate the whole page is built around
115
+
116
+ **A Recommendation CANNOT exist without non-empty `evidence`, a `cost`, and an `undo`.** The
117
+ backend factory throws otherwise (DDD invariant, schema-enforced). The UI must render all four.
118
+
119
+ ```jsonc
120
+ {
121
+ "id": "sync-stack",
122
+ "title": "Sync 1 stale shadow of @ruvector/rvf",
123
+ "rationale": "A second copy in the npx cache preempts your global binary and quietly serves 0.1.9.",
124
+ "severity": "IMPORTANT", // INFO | SUGGESTED | IMPORTANT
125
+ "touchesMachine": true, // ⇐ if true, the UI MUST show plainImpact + require an explicit confirm
126
+ "plainImpact": "This removes an extra, out-of-date copy of a tool sitting in a temporary folder on your computer. Your main copy is newer and stays untouched. Nothing you use will stop working — the temporary copy rebuilds itself automatically the next time it's needed. Fully reversible.",
127
+ "evidence": [ { "observed": "@ruvector/rvf@0.1.9 in ~/.npm/_npx while global is 0.2.3", "source": "stack-sync findShadows" } ],
128
+ "cost": { "time": "~0s", "latency": "none", "usd": 0, "risk": "low" },
129
+ "change": { "kind": "run-script", "human": "purge the stale npx shadow", "cmd": "node scripts/stack-sync.mjs --sync" },
130
+ "undo": { "kind": "restore-dir", "human": "npx re-resolves on next use; backup kept at <dir>.bak-<ts>" }
131
+ }
132
+ ```
133
+
134
+ **`touchesMachine` and `plainImpact` are load-bearing.** `touchesMachine: false` means the action
135
+ only writes RuvNet-Brain's own settings file in your user folder and changes nothing about how your
136
+ computer runs other software (e.g. Save Settings). `touchesMachine: true` means it installs, removes,
137
+ or rewires something the rest of your system uses — those **must** render `plainImpact` (jargon-free,
138
+ says what happens + why it's safe + that it's reversible) and a distinct "this changes your computer"
139
+ confirm step before Apply is allowed. Write `plainImpact` for a smart person who has never heard of npx.
140
+
141
+ ## POST `/api/apply` — the ONLY writer (consent-gated)
142
+
143
+ Request: `{ "token", "ids": ["sync-stack", …], "preStateHash": "…" }`
144
+ Behavior (DDD Change Plan invariants): **re-read the world**, abort with `worldMoved` if `preStateHash`
145
+ no longer matches, **record the inverse first**, back up every mutated file to `<file>.bak-<ts>`, then run.
146
+ Response: `{ "results": [ { "id", "ok", "undoToken", "log" } ] }`
147
+
148
+ ## POST `/api/save-config` — save Settings at user level
149
+
150
+ Request: `{ "token", "values": { … } }` → writes `~/.claude/ruvnet-brain/config.json`
151
+ (backup first, undo recorded). Response: `{ "ok", "backup", "undoToken" }`
152
+
153
+ ## POST `/api/undo` — reverse a prior apply/save
154
+
155
+ Request: `{ "token", "undoToken" }` → Response: `{ "ok" }`
156
+
157
+ ---
158
+
159
+ ## Section order on the page (progressive disclosure — each collapsible, each independently useful)
160
+
161
+ 1. **Your stack** — installed / current / duplicated / broken (from `/api/stack`)
162
+ 2. **How it's wired** — npx vs global, where (from wiring)
163
+ 3. **What we'd suggest** — the Recommendation cards (evidence · cost · undo · Apply/Skip)
164
+ 4. **Is your memory actually working?** — the 0–100 health score with named deductions
165
+ 5. **MetaHarness / Agentic-QE savings** — receipts only, or an honest "nothing measured yet"
166
+ 6. **Settings** — the editable form, one **Save** button, writes at user level
167
+
168
+ ## Design law (from ADR-0013)
169
+ - Read-only by default. Opening the page changes nothing.
170
+ - Existing choices are data, not errors. `AHEAD` is legal. `NPX` is shown with its tradeoff, never labelled "wrong".
171
+ - Every number traces to a receipt or an observation. No "up to 90%". No estimates.
172
+ - Nothing above `SUGGESTED` severity for anything not measured on THIS machine.