@theihtisham/agent-shadow-brain 4.0.3 → 5.0.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.
Files changed (53) hide show
  1. package/README.md +515 -305
  2. package/dist/adapters/index.d.ts.map +1 -1
  3. package/dist/adapters/index.js +1 -0
  4. package/dist/adapters/index.js.map +1 -1
  5. package/dist/brain/auto-setup.d.ts +54 -0
  6. package/dist/brain/auto-setup.d.ts.map +1 -0
  7. package/dist/brain/auto-setup.js +660 -0
  8. package/dist/brain/auto-setup.js.map +1 -0
  9. package/dist/brain/brain-portability.d.ts +81 -0
  10. package/dist/brain/brain-portability.d.ts.map +1 -0
  11. package/dist/brain/brain-portability.js +329 -0
  12. package/dist/brain/brain-portability.js.map +1 -0
  13. package/dist/brain/collective-learning.d.ts +54 -0
  14. package/dist/brain/collective-learning.d.ts.map +1 -0
  15. package/dist/brain/collective-learning.js +357 -0
  16. package/dist/brain/collective-learning.js.map +1 -0
  17. package/dist/brain/consensus-engine.d.ts +65 -0
  18. package/dist/brain/consensus-engine.d.ts.map +1 -0
  19. package/dist/brain/consensus-engine.js +385 -0
  20. package/dist/brain/consensus-engine.js.map +1 -0
  21. package/dist/brain/context-recall.d.ts +49 -0
  22. package/dist/brain/context-recall.d.ts.map +1 -0
  23. package/dist/brain/context-recall.js +502 -0
  24. package/dist/brain/context-recall.js.map +1 -0
  25. package/dist/brain/hierarchical-memory.d.ts +49 -0
  26. package/dist/brain/hierarchical-memory.d.ts.map +1 -0
  27. package/dist/brain/hierarchical-memory.js +451 -0
  28. package/dist/brain/hierarchical-memory.js.map +1 -0
  29. package/dist/brain/mcp-server.d.ts +12 -0
  30. package/dist/brain/mcp-server.d.ts.map +1 -1
  31. package/dist/brain/mcp-server.js +396 -37
  32. package/dist/brain/mcp-server.js.map +1 -1
  33. package/dist/brain/orchestrator.d.ts +34 -0
  34. package/dist/brain/orchestrator.d.ts.map +1 -1
  35. package/dist/brain/orchestrator.js +83 -1
  36. package/dist/brain/orchestrator.js.map +1 -1
  37. package/dist/brain/plugin-system.d.ts +97 -0
  38. package/dist/brain/plugin-system.d.ts.map +1 -0
  39. package/dist/brain/plugin-system.js +404 -0
  40. package/dist/brain/plugin-system.js.map +1 -0
  41. package/dist/cli.js +429 -3
  42. package/dist/cli.js.map +1 -1
  43. package/dist/dashboard/server.d.ts +4 -0
  44. package/dist/dashboard/server.d.ts.map +1 -1
  45. package/dist/dashboard/server.js +453 -330
  46. package/dist/dashboard/server.js.map +1 -1
  47. package/dist/index.d.ts +8 -1
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +10 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/types.d.ts +201 -1
  52. package/dist/types.d.ts.map +1 -1
  53. package/package.json +32 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- <img src="docs/images/v4-banner.svg" alt="Agent Shadow Brain v4.0.0" width="100%">
3
+ <img src="docs/images/v5-banner.svg" alt="Agent Shadow Brain v5.0.1 — Infinite Intelligence Edition" width="100%">
4
4
 
5
5
  <br/>
6
6
 
@@ -11,16 +11,19 @@
11
11
  [![GitHub stars](https://img.shields.io/github/stars/theihtisham/agent-shadow-brain?color=f59e0b&labelColor=1a0a2e&style=for-the-badge&logo=github)](https://github.com/theihtisham/agent-shadow-brain/stargazers)
12
12
  [![arXiv](https://img.shields.io/badge/arXiv-2504.17033-ef4444?labelColor=1a0a2e&style=for-the-badge)](https://arxiv.org/abs/2504.17033)
13
13
  [![ICLR 2026](https://img.shields.io/badge/ICLR-2026_TurboQuant-06b6d4?labelColor=1a0a2e&style=for-the-badge)](https://openreview.net/forum?id=TbqSEUXWaO)
14
+ [![Zero Config](https://img.shields.io/badge/zero-config-auto_setup-22c55e?labelColor=1a0a2e&style=for-the-badge)](#)
15
+ [![MCP](https://img.shields.io/badge/MCP-Cursor_+_Claude-8b5cf6?labelColor=1a0a2e&style=for-the-badge)](#)
16
+ [![Dashboard](https://img.shields.io/badge/dashboard-real_time-06b6d4?labelColor=1a0a2e&style=for-the-badge)](#)
14
17
 
15
18
  <br/>
16
19
 
17
- ### **The World's First Hyper-Intelligent AI Coding Brain**
20
+ ### **The World's #1 Infinite-Intelligence AI Coding Brain**
18
21
 
19
- **Shadow Brain** is a self-evolving, infinite-memory intelligence layer for AI coding agents. It watches your code, applies **mathematically proven algorithms** from cutting-edge research, learns across sessions with **zero forgetting**, and makes every AI agent write **better, safer, faster code** — forever.
22
+ **Shadow Brain** is a zero-config, self-evolving, infinite-memory intelligence layer that makes **every AI coding agent** write better, safer, faster code. Install it once, and it automatically detects your project, your AI tools, your frameworks — and starts making your agents smarter forever.
20
23
 
21
- > **v4.0.0 — Hyper-Intelligence Edition**: TurboQuant infinite memory (Google Research, ICLR 2026), SSSP O(m log<sup>2/3</sup>n) routing (arXiv 2504.17033), self-evolving genetic rules, cross-agent protocol, adversarial hallucination defense, swarm intelligence, knowledge graph with PageRank.
24
+ > **v5.0.1 — Infinite Intelligence Edition**: Zero-config auto-setup with MCP server for **Claude Code + Cursor + 8 AI tools**, rich web dashboard with real-time WebSocket updates, natural language brain queries, plugin system, brain export/import for team sync, git hook integration, and all v5.0.0 infinite intelligence features — 4-tier hierarchical memory, context-triggered associative recall, multi-agent consensus, collective cross-project learning, TurboQuant 6x compression, SSSP routing, self-evolving genetic rules, adversarial hallucination defense, swarm intelligence, knowledge graph with PageRank, and predictive bug forecasting.
22
25
 
23
- [**Install Now**](#-getting-started) · [**v4.0.0 Modules**](#-v40-hyper-intelligence-engine) · [**Algorithms**](#-algorithms--research) · [**CLI Reference**](#-cli-reference) · [**Architecture**](#-architecture)
26
+ [**Install Now**](#-getting-started-30-seconds) · [**Dashboard**](#-web-dashboard) · [**v5.0.1 New**](#-v501-whats-new) · [**Algorithms**](#-algorithms--research) · [**CLI Reference**](#-cli-reference) · [**Architecture**](#-architecture)
24
27
 
25
28
  </div>
26
29
 
@@ -33,38 +36,318 @@ You use AI coding agents. They're powerful, but:
33
36
  | Problem | Impact |
34
37
  |---|---|
35
38
  | Agents **forget everything** between sessions | Same mistakes, zero learning |
36
- | Multiple agents **don't communicate** | Claude doesn't know what Cline learned |
39
+ | Multiple agents **don't communicate** | Claude doesn't know what Cursor learned |
37
40
  | Generated code has **hallucinations** | LLMs fabricate APIs that don't exist |
38
41
  | No **cross-session memory** | Every conversation starts from zero |
39
- | Agents can't **predict bugs** | Reactive, not proactive |
40
- | No **self-improvement** | Rules never get better on their own |
42
+ | No **cross-project learning** | Discoveries in one project don't help others |
43
+ | Setup is **complicated** | 30 minutes of config before anything works |
44
+ | Each tool needs **separate config** | Claude, Cursor, Cline all need different setup |
41
45
 
42
46
  ## The Solution
43
47
 
44
- **Shadow Brain v4.0.0** runs alongside your agents as a *hyper-intelligent shadow layer*:
48
+ **Shadow Brain v5.0.1** — zero-config, auto-detecting, infinite-intelligence shadow layer:
45
49
 
46
50
  ```
47
- ┌──────────────┐ watches ┌────────────────────────────────────┐ injects ┌──────────────┐
48
- │ AI Agents │ ─────────────▶ │ SHADOW BRAIN v4.0.0 │ ────────────▶ │ AI Agents │
49
- │ Claude Code │ file changes │ │ insights + │ Smarter │
50
- │ Kilo Code │ git commits │ TurboQuant ─── Infinite Memory │ context + │ Safer │
51
- │ Cline │ activity │ SSSP BMSSP ─── Quantum Routing │ fixes + │ Faster │
52
- │ OpenCode │ │ Self-Evolution ─ Living Rules │ predictions │ Connected │
53
- │ Codex │ │ CAIP ───────── Cross-Agent Sync │ │ Evolving │
54
- │ Roo Code │ │ Swarm ──────── File Hotspots │ │ Predictive │
55
- │ Aider │ │ PageRank ───── Impact Radar │ │ Trusted │
56
- └──────────────┘ │ Adversarial ── Trust Verification │ └──────────────┘
57
- ▲ └────────────────────────────────────┘ ▲
58
- │ ▲ ▲ ▲ │
59
- └──────────────────────────────┘──────────┘──────────┘───────────────────────────────┘
60
- shares insights across all agents via Cross-Agent Intelligence Protocol
51
+ ┌──────────────┐ auto-detect ┌──────────────────────────────────────────┐
52
+ │ AI Agents │ ◀──────────────── │ SHADOW BRAIN v5.0.1 │
53
+ │ Claude Code │ MCP auto-install │ │
54
+ │ Cursor │ zero-config │ ┌─ ZERO-CONFIG (v5.0.1 NEW) ────────┐ │
55
+ │ Kilo Code │ │ │ Auto-detect project, tools, langs │ │
56
+ │ Cline │ watches │ │ MCP server for ALL AI tools │ │
57
+ │ OpenCode │ ──────────────▶ │ │ Rich web dashboard (real-time) │ │
58
+ │ Codex │ file changes │ │ Natural language brain queries │ │
59
+ │ Roo Code │ git commits │ │ Plugin system + export/import │ │
60
+ │ Aider │ activity │ └────────────────────────────────────┘ │
61
+ │ Windsurf │ │ ┌─ INFINITE MEMORY (v5.0.0) ────────┐ │
62
+ └──────────────┘ │ │ 4-tier hierarchical compression │ │
63
+ ▲ │ │ Context-triggered recall │ │
64
+ │ │ │ Multi-agent consensus + trust │ │
65
+ │ │ │ Collective cross-project learning │ │
66
+ │ │ └────────────────────────────────────┘ │
67
+ │ │ ┌─ HYPER-INTELLIGENCE (v4) ──────────┐ │
68
+ │ │ │ TurboQuant 6x Compression │ │
69
+ │ │ │ SSSP BMSSP Quantum Routing │ │
70
+ │ │ │ Self-Evolution + CAIP + Swarm │ │
71
+ │ │ │ PageRank + Predictive + Adversarial │ │
72
+ └──────────────────────────┴──────────────────────────────────────────┘
61
73
  ```
62
74
 
63
75
  ---
64
76
 
77
+ ## v5.0.1 — What's New
78
+
79
+ ### Zero-Config Auto-Setup
80
+
81
+ Install it. That's it. Shadow Brain automatically:
82
+
83
+ - Detects your project type (frontend, backend, fullstack, mobile, game, systems, data-science)
84
+ - Detects 25+ languages, 15+ frameworks, 5+ build tools, 5+ test frameworks
85
+ - Detects which AI tools are installed (Claude Code, Cursor, Kilo Code, Cline, OpenCode, Codex, Aider, Windsurf)
86
+ - Auto-installs MCP server configuration for every detected AI tool
87
+ - Auto-installs git pre-commit and pre-push hooks
88
+ - Generates an optimal brain config based on project complexity
89
+
90
+ ```bash
91
+ npm install @theihtisham/agent-shadow-brain
92
+ # → Shadow Brain v5.0.1 auto-configured for my-app (fullstack)
93
+ # → AI tools detected: Claude Code, Cursor
94
+ # → Run: shadow-brain start
95
+ ```
96
+
97
+ ### MCP Server — Works with EVERY AI Tool
98
+
99
+ The brain exposes itself as a **Model Context Protocol (MCP) server** with 19 tools that any AI tool can call:
100
+
101
+ | MCP Tool | What It Does |
102
+ |---|---|
103
+ | `brain_status` | Get full brain status |
104
+ | `brain_analyze` | Trigger code analysis |
105
+ | `brain_health` | Get health score (A-F) |
106
+ | `brain_insights` | Get recent insights |
107
+ | `brain_fixes` | Get smart fix suggestions |
108
+ | `brain_memory_store` | Store knowledge in hierarchical memory |
109
+ | `brain_memory_search` | Search across all memory tiers |
110
+ | `brain_memory_stats` | Memory compression statistics |
111
+ | `brain_recall` | Context-triggered associative recall |
112
+ | `brain_consensus_propose` | Submit a proposal for agent consensus |
113
+ | `brain_consensus_vote` | Vote on a pending proposal |
114
+ | `brain_collective_propose` | Propose a cross-project rule |
115
+ | `brain_collective_search` | Search collective learning rules |
116
+ | `brain_turbo_search` | Semantic search in compressed memory |
117
+ | `brain_predict` | Predict bug risk for files |
118
+ | `brain_graph_query` | Query knowledge graph |
119
+ | `brain_defense_scan` | Scan for hallucination patterns |
120
+ | `brain_evolve_status` | Get self-evolution status |
121
+ | `brain_dashboard_url` | Get dashboard URL |
122
+
123
+ Works with **Claude Code**, **Cursor**, **Kilo Code**, **Cline**, **OpenCode**, and any MCP-compatible AI tool.
124
+
125
+ ```bash
126
+ # Start MCP server (auto-started by AI tools)
127
+ shadow-brain mcp
128
+
129
+ # Cursor compatibility (root path POST + /v1/chat)
130
+ # Claude Code compatibility (JSON-RPC 2.0 over stdio/HTTP)
131
+ ```
132
+
133
+ ### Rich Web Dashboard
134
+
135
+ Real-time browser dashboard at `http://localhost:7341` with WebSocket live updates:
136
+
137
+ - **Stats Topbar**: 8 live counters — Insights, Fixes, Memory KB, Modules, AI Tools, Evolution Gen, Swarm Convergence, Turbo Compression
138
+ - **Health Score**: A-F grading with dimension breakdown (Security, Quality, Performance, Architecture, Maintainability, Test Coverage)
139
+ - **Memory Tiers**: Visual bars showing Raw (50K), Summary (10K), Pattern (2K), Principle (500) with Turbo compression ratio
140
+ - **Live Insights Stream**: Real-time feed of brain insights with priority badges
141
+ - **Smart Fixes**: Actionable fix suggestions with file/line references
142
+ - **AI Tools Panel**: 8 tools showing connected/detected status
143
+ - **Brain Modules**: 13 modules with active/idle/error indicators
144
+ - **Control Buttons**: Trigger analysis on-demand, refresh data
145
+
146
+ ```bash
147
+ shadow-brain start . # Dashboard auto-starts at http://localhost:7341
148
+ shadow-brain dash . # Dashboard only mode
149
+ ```
150
+
151
+ ### Natural Language Queries
152
+
153
+ Ask your brain questions in plain English:
154
+
155
+ ```bash
156
+ shadow-brain ask "What security issues exist in the auth module?"
157
+ shadow-brain ask "Which files have the highest bug risk?"
158
+ shadow-brain ask "What patterns have we learned about React hooks?"
159
+ ```
160
+
161
+ ### Brain Export/Import — Team Sync
162
+
163
+ Export your brain state and share it with your team:
164
+
165
+ ```bash
166
+ shadow-brain export # Full export with all modules
167
+ shadow-brain export -o ./team-brain # Custom output directory
168
+ shadow-brain import brain-export.json # Import + merge
169
+ shadow-brain import brain-export.json --merge --skip swarm,evolution
170
+ ```
171
+
172
+ ### Plugin System
173
+
174
+ Extend Shadow Brain with custom plugins:
175
+
176
+ ```bash
177
+ shadow-brain plugin list # List installed plugins
178
+ shadow-brain plugin create my-plugin # Create from template
179
+ shadow-brain plugin stats # Plugin system statistics
180
+ ```
181
+
182
+ Plugins can hook into `pre-analysis` and `post-analysis` pipelines to add custom insights, filter results, or integrate with external services.
183
+
184
+ ### 5 New Commands
185
+
186
+ ```bash
187
+ shadow-brain off # Clean shutdown
188
+ shadow-brain ask "..." # Natural language query
189
+ shadow-brain export # Export brain state
190
+ shadow-brain import FILE # Import brain state
191
+ shadow-brain plugin CMD # Plugin management
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Getting Started — 30 Seconds
197
+
198
+ ```bash
199
+ # Install globally
200
+ npm install -g @theihtisham/agent-shadow-brain
201
+
202
+ # Or use npx (no install needed)
203
+ npx @theihtisham/agent-shadow-brain start .
204
+ ```
205
+
206
+ That's literally it. Shadow Brain will:
207
+ 1. **Auto-detect** your project, languages, frameworks, AI tools (zero config)
208
+ 2. **Auto-install** MCP server config for Claude Code, Cursor, Kilo Code, Cline, etc.
209
+ 3. **Auto-install** git hooks for pre-commit and pre-push
210
+ 4. Watch your project files for changes
211
+ 5. Analyze every change with LLM + 13 brain modules
212
+ 6. Inject expert insights into your agent's memory
213
+ 7. Store all knowledge in hierarchical memory for infinite retention
214
+ 8. Activate past memories automatically based on context
215
+ 9. Share verified patterns across projects via collective learning
216
+ 10. Compress knowledge with TurboQuant for infinite retention
217
+ 11. Evolve its own rules via genetic algorithm
218
+ 12. Share insights across agents via CAIP
219
+ 13. Detect hallucinations with adversarial verification
220
+ 14. Run consensus when multiple agents disagree
221
+ 15. Serve a rich web dashboard at `localhost:7341`
222
+
223
+ ### Quick Review (No Watch Mode)
224
+
225
+ ```bash
226
+ shadow-brain review . # One-shot analysis
227
+ shadow-brain review . --show-health # + health score
228
+ shadow-brain review . --show-fixes # + fix suggestions
229
+ shadow-brain review . --output json # JSON for scripting
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Web Dashboard
235
+
236
+ The v5.0.1 dashboard provides a real-time view into your brain:
237
+
238
+ ```
239
+ ┌──────────────────────────────────────────────────────────────────────────┐
240
+ │ Shadow Brain v5.0.1 [Analyze] [↻] │
241
+ ├──────────────────────────────────────────────────────────────────────────┤
242
+ │ Insights: 142 │ Fixes: 38 │ Memory: 247KB │ Modules: 13/13 │ ... │
243
+ ├──────────────┬─────────────────────────────────────┬───────────────────┤
244
+ │ Health: 87% │ Live Insights Stream │ AI Tools │
245
+ │ ████████░░ │ ● [HIGH] SQL injection in login.ts │ ● Claude Code ✓ │
246
+ │ Security: A │ ● [MED] Missing error handling │ ● Cursor ✓ │
247
+ │ Quality: B+ │ ● [LOW] Unused import in utils │ ● Kilo Code ✓ │
248
+ │ Perf: A- │ ● [CRIT] Exposed API key │ ● Cline — │
249
+ │ Arch: B │ │ ● OpenCode — │
250
+ │ Maintain: A ├─────────────────────────────────────┤ ● Codex — │
251
+ │ Tests: C+ │ Smart Fixes │ ● Aider — │
252
+ │ │ 1. Add parameterized query... │ ● Windsurf — │
253
+ ├──────────────┤ 2. Wrap in try/catch with... ├───────────────────┤
254
+ │ Memory Tiers │ 3. Remove unused import on L42 │ Brain Modules │
255
+ │ Raw: 8421 │ │ ● Hierarchical ✓ │
256
+ │ Summ: 1203 │ │ ● TurboMemory ✓ │
257
+ │ Patt: 187 │ │ ● Consensus ✓ │
258
+ │ Princ: 24 │ │ ● Swarm ✓ │
259
+ │ Turbo: 6.2x │ │ ● Evolution ✓ │
260
+ │ │ │ ● Adversarial ✓ │
261
+ └──────────────┴─────────────────────────────────────┴───────────────────┘
262
+ ```
263
+
264
+ ---
265
+
266
+ ## v5.0.0 Infinite Intelligence Engine
267
+
268
+ ### 4 Breakthrough Modules
269
+
270
+ <table>
271
+ <tr>
272
+ <td width="50%">
273
+
274
+ ### Infinite Memory Layer
275
+
276
+ **Hierarchical Memory Compression** — 4-tier pyramid that never forgets.
277
+
278
+ Knowledge flows through compression tiers as it ages:
279
+ - **Raw** (50K entries) — full detail, hot path
280
+ - **Summary** (10K) — condensed key points
281
+ - **Pattern** (2K) — recurring patterns extracted
282
+ - **Principle** (500) — timeless design rules
283
+
284
+ Drill-down and drill-up between tiers. Older knowledge compresses, never deletes.
285
+
286
+ ```bash
287
+ shadow-brain memory stats # 4 tiers | 12,847 entries
288
+ shadow-brain memory store "..." # Store new knowledge
289
+ shadow-brain memory search "auth" # Cross-tier semantic search
290
+ ```
291
+
292
+ **Context-Triggered Associative Recall** — memories that activate themselves.
293
+
294
+ Instead of requiring explicit search queries, this engine monitors your current work context and automatically surfaces relevant past knowledge:
295
+ - File path pattern matching (editing `auth/*.ts` → security memories)
296
+ - Keyword detection (typing "database" → SQL pattern memories)
297
+ - Category association (bug-fix context → past fix patterns)
298
+ - Co-occurrence networks (memories activated together strengthen their link)
299
+ - Learned trigger patterns that improve with use
300
+
301
+ ```bash
302
+ shadow-brain recall . --file src/auth/login.ts --keywords "jwt,session"
303
+ # → Activates 8 memories | Top: "JWT rotation pattern (92%)"
304
+ ```
305
+
306
+ </td>
307
+ <td width="50%">
308
+
309
+ ### Multi-Agent Intelligence Layer
310
+
311
+ **Consensus Engine** — voting, trust scoring, conflict resolution.
312
+
313
+ When multiple AI agents observe the same codebase, they may produce conflicting insights. This engine:
314
+ 1. Collects proposals from agents
315
+ 2. Opens voting windows (agree/disagree/abstain with confidence)
316
+ 3. Computes trust-weighted agreement scores
317
+ 4. Resolves conflicts via confidence intervals
318
+ 5. Tracks long-term agent trust based on proposal accuracy
319
+
320
+ ```bash
321
+ shadow-brain consensus status
322
+ shadow-brain consensus propose "Use bcrypt for all password hashing" security 0.95
323
+ shadow-brain consensus vote <id> agree 0.9 "Industry standard"
324
+ shadow-brain consensus results
325
+ ```
326
+
327
+ **Collective Learning** — discoveries flow across all projects.
328
+
329
+ When you discover a pattern in Project A, it becomes a verified rule available in Project B:
330
+ - Rule proposal with evidence and verification
331
+ - Viral propagation across connected brain instances
332
+ - Accuracy tracking per rule (tested vs. false positive)
333
+ - Category-based organization (security, performance, architecture...)
334
+ - Trust scores for rule sources
335
+
336
+ ```bash
337
+ shadow-brain collective status
338
+ shadow-brain collective propose "Always validate file upload MIME types" security
339
+ shadow-brain collective search performance
340
+ ```
341
+
342
+ </td>
343
+ </tr>
344
+ </table>
345
+
346
+ ---
347
+
65
348
  ## v4.0.0 Hyper-Intelligence Engine
66
349
 
67
- ### 8 New Breakthrough Modules
350
+ ### 8 Breakthrough Modules (included in v5.0.1)
68
351
 
69
352
  <table>
70
353
  <tr>
@@ -77,11 +360,11 @@ You use AI coding agents. They're powerful, but:
77
360
  Based on Google Research's **TurboQuant** (ICLR 2026):
78
361
  - **PolarQuant**: 2 bits per dimension (polar coordinate quantization)
79
362
  - **QJL Residual**: 1 bit per dimension (random rotation + sign)
80
- - **Total**: 3 bits/dim = **6x compression** with &lt;1% accuracy loss
363
+ - **Total**: 3 bits/dim = **6x compression** with <1% accuracy loss
81
364
  - **Result**: Infinite retention — old knowledge is compressed, never deleted
82
365
 
83
366
  ```bash
84
- shadow-brain turbo stats # 0 entries | 6x compressed
367
+ shadow-brain turbo stats
85
368
  shadow-brain turbo search "authentication patterns"
86
369
  ```
87
370
 
@@ -90,11 +373,10 @@ shadow-brain turbo search "authentication patterns"
90
373
  Based on **"Breaking the Sorting Barrier"** (arXiv 2504.17033, Duan et al.):
91
374
  - **BMSSP Algorithm**: O(m log<sup>2/3</sup> n) — breaks the sorting barrier
92
375
  - **Deterministic**: No randomization, provably correct
93
- - **Application**: Neural mesh messages find optimal paths between brain nodes
94
376
 
95
377
  ```bash
96
- shadow-brain route status # 5 nodes | BMSSP active
97
- shadow-brain route find node-A node-B # → [node-A, node-C, node-B]
378
+ shadow-brain route status
379
+ shadow-brain route find node-A node-B
98
380
  ```
99
381
 
100
382
  </td>
@@ -104,30 +386,28 @@ shadow-brain route find node-A node-B # → [node-A, node-C, node-B]
104
386
 
105
387
  **Genetic Algorithm Self-Evolution** — rules that write themselves.
106
388
 
107
- Inspired by evolutionary computation:
108
389
  - **Population**: 50 genetic rule chromosomes
109
390
  - **Selection**: Tournament (k=5) — survival of the fittest
110
391
  - **Crossover**: Single-point recombination
111
- - **Mutation**: Gaussian noise (Box-Muller transform, σ=0.1)
112
- - **Fitness**: accuracy × coverage × (1 / falsePositiveRate)
113
- - **Meta-Learning**: Bayesian updating per (strategy, category) pair
392
+ - **Mutation**: Gaussian noise (Box-Muller transform, sigma=0.1)
393
+ - **Fitness**: accuracy x coverage x (1 / falsePositiveRate)
114
394
 
115
395
  ```bash
116
- shadow-brain evolve status # Generation 47 | Best: 0.943
117
- shadow-brain evolve run # Evolve one generation
118
- shadow-brain evolve best-rules security # Top 5 evolved rules
396
+ shadow-brain evolve status
397
+ shadow-brain evolve run
398
+ shadow-brain evolve best-rules security
119
399
  ```
120
400
 
121
401
  **Cross-Agent Intelligence Protocol (CAIP)** — agents that talk to each other.
122
402
 
123
- Your Claude Code session learns what your Cline session discovered:
403
+ Your Claude Code session learns what your Cursor session discovered:
124
404
  - Zero-config broadcast protocol
125
405
  - Agent identification + insight tagging
126
406
  - Multi-agent consensus building
127
407
 
128
408
  ```bash
129
- shadow-brain caip status # 3 agents connected
130
- shadow-brain caip broadcast "Security pattern detected in auth/"
409
+ shadow-brain caip status
410
+ shadow-brain caip broadcast "Security pattern detected"
131
411
  ```
132
412
 
133
413
  </td>
@@ -139,27 +419,23 @@ shadow-brain caip broadcast "Security pattern detected in auth/"
139
419
 
140
420
  **Adversarial Hallucination Defense** — trust nothing, verify everything.
141
421
 
142
- LLMs hallucinate. Shadow Brain catches it:
143
422
  - Cross-reference every critical insight against actual code
144
423
  - Evidence scoring with confidence thresholds
145
424
  - Verdict: `real` | `hallucinated` | `uncertain`
146
- - Tracks accuracy, false positive rate, blocked count
147
425
 
148
426
  ```bash
149
- shadow-brain defense status # Accuracy: 97.3% | Blocked: 12
427
+ shadow-brain defense status
150
428
  shadow-brain defense scan "This API endpoint exists at /api/v2/users"
151
429
  ```
152
430
 
153
431
  **Swarm Intelligence** — Ant Colony Optimization for file prioritization.
154
432
 
155
- Files with more bugs get more pheromone. Analysis focuses where it matters:
156
433
  - Pheromone deposit: +3 for critical, +2 for high, +1 for medium
157
434
  - Evaporation: decay over time to avoid staleness
158
- - Convergence score: measures how focused the swarm is
159
435
 
160
436
  ```bash
161
- shadow-brain swarm status # Convergence: 0.847
162
- shadow-brain swarm priorities # Top 10 hotspot files
437
+ shadow-brain swarm status
438
+ shadow-brain swarm priorities
163
439
  ```
164
440
 
165
441
  </td>
@@ -169,27 +445,24 @@ shadow-brain swarm priorities # Top 10 hotspot files
169
445
 
170
446
  **Knowledge Graph + PageRank** — code impact radar.
171
447
 
172
- Builds a directed graph of code entities, then runs **PageRank** (d=0.85):
173
448
  - Identify high-impact files (change one, break many)
174
449
  - Cycle detection in dependency graphs
175
450
  - Entity extraction with file/line tracking
176
451
 
177
452
  ```bash
178
- shadow-brain graph build . # 342 entities | PageRank computed
179
- shadow-brain graph pagerank # Top 10 most impactful files
180
- shadow-brain graph cycles # Detect circular dependencies
453
+ shadow-brain graph build .
454
+ shadow-brain graph pagerank
455
+ shadow-brain graph cycles
181
456
  ```
182
457
 
183
458
  **Predictive Engine** — predict bugs before they happen.
184
459
 
185
- Analyzes code age, churn rate, staleness, and author patterns:
186
460
  - Bug risk scoring: `low` | `medium` | `high` | `critical`
187
461
  - Technical debt forecasting
188
462
  - Anomaly detection in change patterns
189
- - Factors: days since modification, lines changed, churn rate, staleness
190
463
 
191
464
  ```bash
192
- shadow-brain predict bugs . # 3 high-risk files detected
465
+ shadow-brain predict bugs .
193
466
  ```
194
467
 
195
468
  </td>
@@ -200,11 +473,14 @@ shadow-brain predict bugs . # 3 high-risk files detected
200
473
 
201
474
  ## Algorithms & Research
202
475
 
203
- Shadow Brain v4.0.0 implements algorithms from **peer-reviewed research**:
476
+ Shadow Brain v5.0.1 implements algorithms from **peer-reviewed research**:
204
477
 
205
478
  | Algorithm | Paper / Origin | Application | Complexity |
206
479
  |---|---|---|---|
207
- | **TurboQuant** | Google Research, ICLR 2026 | Infinite memory compression (PolarQuant + QJL) | O(n) per vector |
480
+ | **Hierarchical Compression** | Novel 4-tier system | Infinite memory with drill-down | O(n) per tier |
481
+ | **Associative Recall** | Spreading activation model | Context-triggered memory activation | O(n x k) |
482
+ | **Consensus Protocol** | Byzantine fault tolerance | Multi-agent agreement with trust | O(v x log v) |
483
+ | **TurboQuant** | Google Research, ICLR 2026 | Vector compression (PolarQuant + QJL) | O(n) per vector |
208
484
  | **BMSSP (SSSP)** | arXiv 2504.17033, Duan et al. | Neural mesh message routing | O(m log<sup>2/3</sup> n) |
209
485
  | **Shannon Entropy** | Claude Shannon, 1948 | Cross-project insight relevance scoring | O(n) |
210
486
  | **Bayesian Inference** | Thomas Bayes, 1763 | Confidence updating, meta-learning | O(1) per update |
@@ -213,44 +489,30 @@ Shadow Brain v4.0.0 implements algorithms from **peer-reviewed research**:
213
489
  | **Tarjan's SCC** | Robert Tarjan, 1972 | Dependency cycle detection | O(V + E) |
214
490
  | **Winnowing** | Schleimer et al., 2003 | Code duplicate fingerprinting | O(n) |
215
491
  | **Box-Muller** | Box & Muller, 1958 | Gaussian mutation in genetic algorithm | O(1) per sample |
216
- | **Ant Colony (ACO)** | Dorigo, 1992 | File priority pheromone system | O(n × m) |
492
+ | **Ant Colony (ACO)** | Dorigo, 1992 | File priority pheromone system | O(n x m) |
217
493
  | **Tournament Selection** | Goldberg, 1989 | Genetic rule selection (k=5) | O(k) per selection |
218
- | **Polar Coordinates** | Classical mathematics | Vector compression via angle quantization | O(n) |
219
494
 
220
495
  ### TurboQuant Pipeline Detail
221
496
 
222
497
  ```
223
498
  Input Vector (64-dim, float64)
224
- │
225
- ▼
226
- ┌─────────────┐
227
- │ PolarQuant │── Cartesian → Polar coordinates
228
- │ 2 bits/dim │── Quantize angles to 4 levels (2 bits each)
229
- └──────┬──────┘ Pack into Uint8Array
230
- │
231
- ▼
232
- ┌─────────────┐
233
- │ QJL Residual│── Random rotation (Hadamard-like)
234
- │ 1 bit/dim │── Sign extraction (1 bit per dim)
235
- └──────┬──────┘ Pack into Uint8Array
236
- │
237
- ▼
499
+ |
500
+ v
501
+ +-------------+
502
+ | PolarQuant |-- Cartesian -> Polar coordinates
503
+ | 2 bits/dim |-- Quantize angles to 4 levels (2 bits each)
504
+ +------+-------+ Pack into Uint8Array
505
+ |
506
+ v
507
+ +-------------+
508
+ | QJL Residual|-- Random rotation (Hadamard-like)
509
+ | 1 bit/dim |-- Sign extraction (1 bit per dim)
510
+ +------+-------+ Pack into Uint8Array
511
+ |
512
+ v
238
513
  TurboVector { polar: Uint8Array, qjl: Uint8Array, dim: number, radius: number }
239
514
  = 3 bits/dim total = 6x compression from float64
240
- = ZERO FORGETTING — compressed knowledge stays searchable forever
241
- ```
242
-
243
- ### SSSP BMSSP Algorithm
244
-
245
- ```
246
- Traditional Dijkstra: O(m + n log n) ── limited by comparison sorting
247
- Bellman-Ford: O(mn) ── too slow for large meshes
248
-
249
- BMSSP (2025): O(m log^(2/3) n) ── BREAKS THE SORTING BARRIER
250
- └─ Uses approximate bucketing instead of exact comparison sort
251
- └─ Deterministic (no randomization)
252
- └─ Provably correct shortest paths
253
- └─ Applied to neural mesh message routing between brain nodes
515
+ = ZERO FORGETTING -- compressed knowledge stays searchable forever
254
516
  ```
255
517
 
256
518
  ---
@@ -259,73 +521,51 @@ BMSSP (2025): O(m log^(2/3) n) ── BREAKS THE SORTING BARRIER
259
521
 
260
522
  <table>
261
523
  <tr>
262
- <td width="33%">
263
-
264
- ### Real-Time Intelligence
265
- - File watching (chokidar)
266
- - Git monitoring (commits, diffs)
267
- - LLM-powered analysis (Anthropic, OpenAI, Ollama, OpenRouter)
268
- - Pattern memory across sessions
269
- - Learning engine (automatic)
270
-
271
- </td>
272
- <td width="33%">
273
-
274
- ### Security & Quality
275
- - Vulnerability scanner
276
- - Custom rules engine (regex)
277
- - Framework presets (React, Next.js, Django, FastAPI)
278
- - Smart fix engine with confidence scores
279
- - Type safety analyzer
280
-
281
- </td>
282
- <td width="33%">
283
-
284
- ### Health & Metrics
285
- - A-F health grading (6 dimensions)
286
- - Code metrics (LOC, complexity, languages)
287
- - SVG health badges
288
- - Trend tracking
289
- - Performance profiler
290
-
291
- </td>
292
- </tr>
293
- <tr>
294
- <td width="33%">
524
+ <td width="25%">
295
525
 
296
- ### Multi-Agent (7 Adapters)
297
- - Claude Code → `CLAUDE.md`
298
- - Kilo Code → `.kilocode/rules.md`
299
- - Cline → `.clinerules`
300
- - OpenCode → `AGENT.md`
301
- - Codex → `AGENTS.md`
302
- - Roo Code → `.roo/rules.md`
303
- - Aider → `.aider.conf.yml`
526
+ ### Zero Config (v5.0.1)
527
+ - Auto-detect project + tools
528
+ - MCP for ALL AI tools
529
+ - Rich web dashboard
530
+ - Natural language queries
531
+ - Plugin system
532
+ - Brain export/import
533
+ - Git hook auto-install
304
534
 
305
535
  </td>
306
- <td width="33%">
536
+ <td width="25%">
307
537
 
308
- ### Developer Experience
309
- - **40+ CLI commands** — full terminal control
310
- - MCP Server — Model Context Protocol
311
- - Web dashboard — `localhost:7341`
312
- - Terminal UI — Ink/React dashboard
313
- - Pre-commit hooks — block bad commits
314
- - GitHub Actions — CI integration
538
+ ### Infinite Intelligence (v5)
539
+ - 4-tier hierarchical memory
540
+ - Context-triggered recall
541
+ - Multi-agent consensus
542
+ - Collective cross-project learning
315
543
 
316
544
  </td>
317
- <td width="33%">
545
+ <td width="25%">
318
546
 
319
- ### v4.0.0 Hyper-Intelligence
547
+ ### Hyper-Intelligence (v4)
320
548
  - TurboQuant infinite memory
321
549
  - SSSP quantum routing
322
550
  - Self-evolving genetic rules
323
551
  - Cross-agent protocol (CAIP)
324
- - Adversarial hallucination defense
552
+ - Adversarial defense
325
553
  - Swarm intelligence (ACO)
326
554
  - Knowledge Graph + PageRank
327
555
  - Predictive bug forecasting
328
556
 
557
+ </td>
558
+ <td width="25%">
559
+
560
+ ### Developer Experience
561
+ - **50+ CLI commands**
562
+ - MCP Server (19 tools)
563
+ - Web dashboard (real-time)
564
+ - Terminal UI (Ink/React)
565
+ - Pre-commit hooks
566
+ - GitHub Actions CI
567
+ - Plugin architecture
568
+
329
569
  </td>
330
570
  </tr>
331
571
  </table>
@@ -334,104 +574,27 @@ BMSSP (2025): O(m log^(2/3) n) ── BREAKS THE SORTING BARRIER
334
574
 
335
575
  ## Architecture
336
576
 
337
- <img src="docs/images/v4-architecture.svg" alt="v4.0.0 Architecture" width="100%">
338
-
339
- ### v4.0.0 Module Map
577
+ ### v5.0.1 Module Map (16 modules)
340
578
 
341
- | Module | File | What It Does | Research |
579
+ | Module | File | What It Does | Since |
342
580
  |---|---|---|---|
343
- | **TurboMemory** | `brain/turbo-memory.ts` | 6x compressed infinite memory | Google ICLR 2026 |
344
- | **SSSP Router** | `brain/sssp-router.ts` | Sub-sorting-complexity routing | arXiv 2504.17033 |
345
- | **Self-Evolution** | `brain/self-evolution.ts` | Genetic rule optimization | Goldberg 1989 |
346
- | **Cross-Agent** | `brain/cross-agent-protocol.ts` | Multi-agent broadcast | Novel protocol |
347
- | **Adversarial** | `brain/adversarial-defense.ts` | Hallucination detection | Novel approach |
348
- | **Swarm** | `brain/swarm-intelligence.ts` | File priority pheromones | Dorigo 1992 |
349
- | **Knowledge Graph** | `brain/knowledge-graph.ts` | PageRank impact analysis | Brin & Page 1998 |
350
- | **Predictive** | `brain/predictive-engine.ts` | Bug risk & debt forecasting | Statistical models |
351
-
352
- ---
353
-
354
- ## Getting Started
355
-
356
- ### Install
357
-
358
- ```bash
359
- # Install globally
360
- npm install -g @theihtisham/agent-shadow-brain
361
-
362
- # Or use with npx (no install needed)
363
- npx @theihtisham/agent-shadow-brain review .
364
- ```
365
-
366
- ### One-Command Setup
367
-
368
- ```bash
369
- shadow-brain setup
370
- ```
371
-
372
- ### Start Watching
373
-
374
- ```bash
375
- shadow-brain start .
376
- ```
377
-
378
- That's it. Shadow Brain will:
379
- 1. Auto-detect which AI agents are running (7 supported)
380
- 2. Watch your project files for changes
381
- 3. Analyze every change with LLM + mathematical algorithms
382
- 4. Inject expert insights into your agent's memory
383
- 5. Compress knowledge with TurboQuant for infinite retention
384
- 6. Evolve its own rules via genetic algorithm
385
- 7. Share insights across agents via CAIP
386
- 8. Detect hallucinations with adversarial verification
387
-
388
- ### Quick Review (No Watch Mode)
389
-
390
- ```bash
391
- shadow-brain review . # One-shot analysis
392
- shadow-brain review . --show-health # + health score
393
- shadow-brain review . --show-fixes # + fix suggestions
394
- shadow-brain review . --output json # JSON for scripting
395
- ```
396
-
397
- ### v4.0.0 Commands
398
-
399
- ```bash
400
- # Infinite memory
401
- shadow-brain turbo stats # TurboQuant compression stats
402
- shadow-brain turbo search "auth" # Semantic search in compressed memory
403
-
404
- # Quantum routing
405
- shadow-brain route status # SSSP mesh routing status
406
- shadow-brain route find node-A node-B # Shortest path between brain nodes
407
-
408
- # Cross-agent protocol
409
- shadow-brain caip status # Connected agents
410
- shadow-brain caip broadcast "message" # Broadcast to all agents
411
-
412
- # Self-evolution
413
- shadow-brain evolve status # Genetic algorithm stats
414
- shadow-brain evolve run # Evolve one generation
415
- shadow-brain evolve best-rules security # Top evolved security rules
416
-
417
- # Predictive engine
418
- shadow-brain predict bugs . # Bug risk scoring
419
-
420
- # Knowledge graph
421
- shadow-brain graph build . # Build + PageRank
422
- shadow-brain graph pagerank # Top impact entities
423
-
424
- # Swarm intelligence
425
- shadow-brain swarm status # Convergence + pheromone stats
426
- shadow-brain swarm priorities # File hotspot ranking
427
-
428
- # Adversarial defense
429
- shadow-brain defense status # Accuracy + blocked count
430
- shadow-brain defense scan "claim text" # Verify a specific claim
431
-
432
- # Run EVERYTHING at once
433
- shadow-brain v4 . # Full v4.0.0 hyper-analysis
434
- ```
581
+ | **Auto Setup** | `brain/auto-setup.ts` | Zero-config project + tool detection | v5.0.1 |
582
+ | **MCP Server** | `brain/mcp-server.ts` | 19-tool MCP server for all AI tools | v5.0.1 |
583
+ | **Plugin System** | `brain/plugin-system.ts` | Hookable analysis pipeline | v5.0.1 |
584
+ | **Brain Portability** | `brain/brain-portability.ts` | Export/import brain state | v5.0.1 |
585
+ | **Dashboard** | `dashboard/server.ts` | Real-time WebSocket dashboard | v5.0.1 |
586
+ | **Hierarchical Memory** | `brain/hierarchical-memory.ts` | 4-tier infinite memory | v5.0.0 |
587
+ | **Context Recall** | `brain/context-recall.ts` | Associative memory activation | v5.0.0 |
588
+ | **Consensus Engine** | `brain/consensus-engine.ts` | Multi-agent voting + trust | v5.0.0 |
589
+ | **Collective Learning** | `brain/collective-learning.ts` | Cross-project rule sharing | v5.0.0 |
590
+ | **TurboMemory** | `brain/turbo-memory.ts` | 6x compressed infinite memory | v4.0.0 |
591
+ | **SSSP Router** | `brain/sssp-router.ts` | Sub-sorting routing | v4.0.0 |
592
+ | **Self-Evolution** | `brain/self-evolution.ts` | Genetic rule optimization | v4.0.0 |
593
+ | **Cross-Agent** | `brain/cross-agent-protocol.ts` | Multi-agent broadcast | v4.0.0 |
594
+ | **Adversarial** | `brain/adversarial-defense.ts` | Hallucination detection | v4.0.0 |
595
+ | **Swarm** | `brain/swarm-intelligence.ts` | File priority pheromones | v4.0.0 |
596
+ | **Knowledge Graph** | `brain/knowledge-graph.ts` | PageRank impact analysis | v4.0.0 |
597
+ | **Predictive** | `brain/predictive-engine.ts` | Bug risk & debt forecasting | v4.0.0 |
435
598
 
436
599
  ---
437
600
 
@@ -441,7 +604,8 @@ shadow-brain v4 . # Full v4.0.0 hyper-analysis
441
604
 
442
605
  | Command | Description |
443
606
  |---|---|
444
- | `shadow-brain start [dir]` | Start real-time watching |
607
+ | `shadow-brain start [dir]` | Start real-time watching + dashboard + MCP |
608
+ | `shadow-brain off` | Clean shutdown |
445
609
  | `shadow-brain review [dir]` | One-shot code analysis |
446
610
  | `shadow-brain health [dir]` | Health score (A-F grading) |
447
611
  | `shadow-brain fix [dir]` | Smart fix suggestions |
@@ -453,10 +617,41 @@ shadow-brain v4 . # Full v4.0.0 hyper-analysis
453
617
  | `shadow-brain ci [dir]` | GitHub Actions workflow |
454
618
  | `shadow-brain hook [dir]` | Pre-commit hook |
455
619
  | `shadow-brain dash [dir]` | Web dashboard |
620
+ | `shadow-brain mcp` | MCP server mode |
456
621
  | `shadow-brain inject <msg>` | Inject into agent memory |
457
622
  | `shadow-brain status` | Current configuration |
458
623
  | `shadow-brain setup` | Interactive setup wizard |
459
624
  | `shadow-brain doctor` | Health check & diagnostics |
625
+ | `shadow-brain ask <question>` | Natural language brain query |
626
+
627
+ ### v5.0.1 Commands (NEW)
628
+
629
+ | Command | Description |
630
+ |---|---|
631
+ | `shadow-brain off` | Clean shutdown of all brain processes |
632
+ | `shadow-brain ask <question>` | Natural language query to the brain |
633
+ | `shadow-brain export [-o dir]` | Export full brain state to JSON |
634
+ | `shadow-brain import <file> [--merge]` | Import brain state |
635
+ | `shadow-brain plugin list` | List installed plugins |
636
+ | `shadow-brain plugin create <name>` | Create plugin from template |
637
+ | `shadow-brain plugin stats` | Plugin system statistics |
638
+
639
+ ### v5.0.0 Infinite Intelligence Commands
640
+
641
+ | Command | Description |
642
+ |---|---|
643
+ | `shadow-brain memory stats` | 4-tier hierarchical memory stats |
644
+ | `shadow-brain memory store <text>` | Store knowledge at raw tier |
645
+ | `shadow-brain memory search <query>` | Cross-tier semantic search |
646
+ | `shadow-brain recall . --file <f>` | Context-triggered associative recall |
647
+ | `shadow-brain consensus status` | Multi-agent consensus stats |
648
+ | `shadow-brain consensus propose <text> <cat> <conf>` | Submit proposal for voting |
649
+ | `shadow-brain consensus vote <id> <vote> <conf> <reason>` | Vote on a proposal |
650
+ | `shadow-brain consensus results` | All resolved proposals |
651
+ | `shadow-brain collective status` | Cross-project rule stats |
652
+ | `shadow-brain collective propose <text> <cat>` | Propose a collective rule |
653
+ | `shadow-brain collective search <cat>` | Search collective rules by category |
654
+ | `shadow-brain v5 [dir]` | Run ALL v5.0.0 analyses |
460
655
 
461
656
  ### v4.0.0 Hyper-Intelligence Commands
462
657
 
@@ -479,28 +674,6 @@ shadow-brain v4 . # Full v4.0.0 hyper-analysis
479
674
  | `shadow-brain defense scan <text>` | Scan text for hallucination patterns |
480
675
  | `shadow-brain v4 [dir]` | Run ALL v4.0.0 analyses |
481
676
 
482
- ### Super-Intelligence Commands (v2.0+)
483
-
484
- | Command | Description |
485
- |---|---|
486
- | `shadow-brain semantic [dir]` | Symbol extraction, dead code |
487
- | `shadow-brain deps [dir]` | Dependency graph, cycles, hubs |
488
- | `shadow-brain duplicates [dir]` | Duplicate code detection |
489
- | `shadow-brain adr [dir]` | Architecture Decision Records |
490
- | `shadow-brain typesafety [dir]` | TypeScript type analysis |
491
- | `shadow-brain perf [dir]` | Performance profiling |
492
- | `shadow-brain knowledge [dir]` | Project knowledge base |
493
- | `shadow-brain learn [dir]` | Extract patterns & lessons |
494
-
495
- ### Neural Mesh Commands (v2.1+)
496
-
497
- | Command | Description |
498
- |---|---|
499
- | `shadow-brain mesh status` | Mesh state + quantum state |
500
- | `shadow-brain mesh insights` | Cross-session insights |
501
- | `shadow-brain mesh knowledge` | Shared knowledge base |
502
- | `shadow-brain mesh nodes` | Connected brain nodes |
503
-
504
677
  ---
505
678
 
506
679
  ## Programmatic API
@@ -508,6 +681,13 @@ shadow-brain v4 . # Full v4.0.0 hyper-analysis
508
681
  ```typescript
509
682
  import {
510
683
  Orchestrator,
684
+ AutoSetup,
685
+ PluginSystem,
686
+ BrainPortability,
687
+ HierarchicalMemory,
688
+ ContextRecall,
689
+ ConsensusEngine,
690
+ CollectiveLearning,
511
691
  TurboMemory,
512
692
  SSSPRouter,
513
693
  SelfEvolution,
@@ -519,37 +699,48 @@ import {
519
699
  NeuralMesh,
520
700
  } from '@theihtisham/agent-shadow-brain';
521
701
 
702
+ // v5.0.1 — Zero-config auto-setup
703
+ const setup = new AutoSetup('./my-project');
704
+ const config = await setup.detect();
705
+ // → { projectType: 'fullstack', languages: ['typescript','python'], frameworks: ['next.js'], aiTools: [...] }
706
+ await setup.installMCPForTools(['Claude Code', 'Cursor']);
707
+ await setup.installGitHooks();
708
+
522
709
  // Create the brain
523
710
  const brain = new Orchestrator({
524
711
  provider: 'anthropic',
525
712
  projectDir: './my-project',
526
- agents: ['claude-code', 'cline', 'roo-code'],
713
+ agents: ['claude-code', 'cursor', 'cline'],
527
714
  watchMode: true,
528
715
  autoInject: true,
529
716
  brainPersonality: 'balanced',
530
717
  });
531
718
 
532
- // v4.0.0 — Direct module access
533
- const turbo = new TurboMemory({ maxEntries: 100000 });
534
- await turbo.store('auth-pattern', vector, { category: 'security' });
535
- const results = await turbo.search(queryVector, 10);
536
-
537
- const evolution = new SelfEvolution({ populationSize: 50 });
538
- const snapshot = await evolution.evolve(insights);
539
- console.log(`Generation ${snapshot.generation}, Best fitness: ${snapshot.bestFitness}`);
540
-
541
- const kg = new KnowledgeGraph('./my-project');
542
- await kg.build();
543
- const topEntities = kg.getTopEntities(10);
544
-
545
- const swarm = new SwarmIntelligence();
546
- swarm.initialize(fileList);
547
- swarm.depositPheromone(['src/auth.ts'], 3.0);
548
- const hotspots = swarm.getHighPriorityFiles(10);
719
+ // v5.0.1 — Plugin system
720
+ const plugins = new PluginSystem('./my-project');
721
+ await plugins.loadAll();
722
+ await plugins.preAnalysis({ files: ['src/auth.ts'], projectDir: './my-project' });
723
+
724
+ // v5.0.1 — Brain portability
725
+ const porter = new BrainPortability('./my-project');
726
+ const { filePath, sizeBytes, checksum } = await porter.exportBrain();
727
+
728
+ // v5.0.0 — Infinite Intelligence
729
+ const hmem = new HierarchicalMemory();
730
+ await hmem.store('JWT rotation pattern: rotate every 24h with refresh tokens', 'security', 0.9);
731
+ const results = hmem.search('jwt');
732
+
733
+ const recall = new ContextRecall(hmem);
734
+ const activated = recall.recall({
735
+ currentFile: 'src/auth/login.ts',
736
+ currentCategory: 'security',
737
+ recentEdits: ['src/auth/login.ts', 'src/middleware/auth.ts'],
738
+ projectType: 'node',
739
+ keywords: ['jwt', 'authentication', 'session'],
740
+ });
549
741
 
550
- const defense = new AdversarialDefense();
551
- const flag = await defense.verifyInsight(insight, './my-project');
552
- console.log(`Verdict: ${flag?.verdict}, Confidence: ${flag?.confidence}`);
742
+ const consensus = new ConsensusEngine('my-agent');
743
+ const proposalId = consensus.propose('Use bcrypt cost factor 12', 'security', 0.95);
553
744
 
554
745
  // Start everything
555
746
  await brain.start();
@@ -572,7 +763,27 @@ await brain.start();
572
763
 
573
764
  ## Version History
574
765
 
575
- ### v4.0.0 — Hyper-Intelligence Edition (Current)
766
+ ### v5.0.1 — Zero-Config Intelligence Edition (Current)
767
+ - **Zero-Config Auto-Setup** — auto-detect project, AI tools, languages, frameworks; auto-install MCP config + git hooks
768
+ - **MCP Server** — 19-tool Model Context Protocol server for Claude Code, Cursor, and all AI tools
769
+ - **Rich Web Dashboard** — real-time WebSocket dashboard with 8 panels (health, memory tiers, insights, fixes, AI tools, modules, stats, controls)
770
+ - **Natural Language Queries** — `shadow-brain ask "..."` for plain-English brain interaction
771
+ - **Plugin System** — hookable analysis pipeline with npm plugin discovery
772
+ - **Brain Export/Import** — full brain state portability for team sync and backup
773
+ - **5 new CLI commands** — off, ask, export, import, plugin
774
+ - **Cursor MCP Compatibility** — root path POST + /v1/chat endpoint support
775
+ - **Postinstall Auto-Setup** — runs automatically after npm install
776
+ - **50+ npm keywords** for discoverability
777
+ - All v5.0.0 and v4.0.0 features included and enhanced
778
+
779
+ ### v5.0.0 — Infinite Intelligence Edition
780
+ - **Hierarchical Memory Compression** — 4-tier pyramid (raw -> summary -> pattern -> principle) with drill-down/up
781
+ - **Context-Triggered Associative Recall** — automatic memory activation based on file paths, keywords, categories
782
+ - **Multi-Agent Consensus Protocol** — trust-weighted voting, confidence intervals, conflict resolution
783
+ - **Collective Cross-Project Learning** — verified rule sharing, viral propagation, accuracy tracking
784
+ - **5 new CLI commands** — memory, recall, consensus, collective, v5
785
+
786
+ ### v4.0.0 — Hyper-Intelligence Edition
576
787
  - **TurboQuant Infinite Memory** — 6x compression, zero forgetting (Google Research, ICLR 2026)
577
788
  - **SSSP BMSSP Routing** — O(m log<sup>2/3</sup>n) deterministic routing (arXiv 2504.17033)
578
789
  - **Self-Evolving Genetic Rules** — tournament selection, Gaussian mutation, Bayesian meta-learning
@@ -581,43 +792,34 @@ await brain.start();
581
792
  - **Swarm Intelligence** — Ant Colony pheromone file prioritization
582
793
  - **Knowledge Graph + PageRank** — code impact radar with d=0.85 damping
583
794
  - **Predictive Engine** — bug risk scoring, debt forecasting, anomaly detection
584
- - **9 new CLI commands** — turbo, route, caip, evolve, predict, graph, swarm, defense, v4
585
- - **29 files changed**, 7,000+ lines of new code
586
795
 
587
796
  ### v3.0.0 — Hyper-Intelligence Edition
588
- - Cognitive load analysis
589
- - Security audit engine
590
- - Influence map (cross-file impact)
797
+ - Cognitive load analysis, security audit engine, influence map
591
798
 
592
799
  ### v2.1.0 — Quantum Neural Mesh
593
- - Cross-session shared intelligence
594
- - Shannon entropy relevance scoring
595
- - Cosine similarity knowledge dedup
596
- - Bayesian confidence updating
800
+ - Cross-session shared intelligence, Shannon entropy, cosine similarity, Bayesian confidence
597
801
 
598
802
  ### v2.0.0 — Super-Intelligence Edition
599
- - Semantic analyzer, dependency graph, code similarity
600
- - ADR engine, type safety, performance profiler
601
- - MCP Server, team mode, multi-project
803
+ - Semantic analyzer, dependency graph, code similarity, MCP Server, team mode
602
804
 
603
805
  ### v1.x — Foundation
604
- - 7 agent adapters, health scoring, smart fixes
605
- - Vulnerability scanning, custom rules, notifications
606
- - CI/CD integration, pre-commit hooks
806
+ - 7 agent adapters, health scoring, smart fixes, vulnerability scanning, CI/CD
607
807
 
608
808
  ---
609
809
 
610
- ## Supported Agents
810
+ ## Supported Agents & Tools
611
811
 
612
- | Agent | Status | Injection Target |
613
- |---|---|---|
614
- | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Full Support | `CLAUDE.md`, `.claude/` |
615
- | [Kilo Code](https://kilocode.ai/) | Full Support | `.kilocode/rules.md` |
616
- | [Cline](https://github.com/cline/cline) | Full Support | `.clinerules` |
617
- | [OpenCode](https://github.com/opencode-ai/opencode) | Full Support | `AGENT.md` |
618
- | [Codex](https://github.com/openai/codex) | Full Support | `AGENTS.md` |
619
- | [Roo Code](https://roocode.com/) | Full Support | `.roo/rules.md` |
620
- | [Aider](https://aider.chat/) | Full Support | `.aider.conf.yml` |
812
+ | Agent | Status | MCP Support | Injection Target |
813
+ |---|---|---|---|
814
+ | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Full Support | Auto-install | `CLAUDE.md`, `.claude/` |
815
+ | [Cursor](https://cursor.sh/) | Full Support | Auto-install | `.cursor/mcp.json` |
816
+ | [Kilo Code](https://kilocode.ai/) | Full Support | Auto-install | `.kilocode/rules.md` |
817
+ | [Cline](https://github.com/cline/cline) | Full Support | Auto-install | `.clinerules` |
818
+ | [OpenCode](https://github.com/opencode-ai/opencode) | Full Support | Yes | `AGENT.md` |
819
+ | [Codex](https://github.com/openai/codex) | Full Support | Yes | `AGENTS.md` |
820
+ | [Roo Code](https://roocode.com/) | Full Support | Yes | `.roo/rules.md` |
821
+ | [Aider](https://aider.chat/) | Full Support | Yes | `.aider.conf.yml` |
822
+ | [Windsurf](https://codeium.com/windsurf) | Detection | Yes | `.windsurfrules` |
621
823
 
622
824
  ---
623
825
 
@@ -642,11 +844,19 @@ npm test
642
844
  - [x] ~~Self-evolving rules~~ (v4.0)
643
845
  - [x] ~~Cross-agent protocol~~ (v4.0)
644
846
  - [x] ~~Adversarial hallucination defense~~ (v4.0)
847
+ - [x] ~~Hierarchical memory compression~~ (v5.0)
848
+ - [x] ~~Context-triggered associative recall~~ (v5.0)
849
+ - [x] ~~Multi-agent consensus protocol~~ (v5.0)
850
+ - [x] ~~Collective cross-project learning~~ (v5.0)
851
+ - [x] ~~Zero-config auto-setup~~ (v5.0.1)
852
+ - [x] ~~MCP server for Cursor + all tools~~ (v5.0.1)
853
+ - [x] ~~Rich web dashboard with real-time WebSocket~~ (v5.0.1)
854
+ - [x] ~~Plugin system + brain export/import~~ (v5.0.1)
645
855
  - [ ] **IDE extensions** — VS Code extension for inline insights
646
856
  - [ ] **Custom LLM fine-tuning** — train on your codebase patterns
647
857
  - [ ] **Docker image** — one-command containerized deployment
648
- - [ ] **Web dashboard v2** — React-based interactive analytics
649
858
  - [ ] **Language server** — LSP protocol for real-time feedback
859
+ - [ ] **Web dashboard v3** — collaborative team dashboard
650
860
 
651
861
  ---
652
862
 
@@ -673,6 +883,6 @@ MIT License — see [LICENSE](LICENSE) for details.
673
883
 
674
884
  **Built with brains by [theihtisham](https://github.com/theihtisham)**
675
885
 
676
- **Topics:** `ai` `artificial-intelligence` `llm` `claude-code` `cline` `kilo-code` `codex` `roo-code` `aider` `opencode` `code-review` `static-analysis` `developer-tools` `npm-package` `typescript` `ollama` `openai` `anthropic` `code-quality` `security-scanner` `health-score` `smart-fix` `vulnerability-scanner` `pattern-learning` `agent-tools` `ai-agent` `code-metrics` `pre-commit-hook` `github-actions` `developer-productivity` `neural-mesh` `quantum-computing` `shannon-entropy` `bayesian-inference` `mcp-server` `semantic-analysis` `dependency-graph` `turboquant` `sssp-algorithm` `genetic-algorithm` `swarm-intelligence` `pagerank` `knowledge-graph` `hallucination-detection` `cross-agent` `self-evolving` `predictive-engine` `ant-colony` `infinite-memory` `vector-compression` `iclr-2026` `arxiv` `super-intelligence` `hyper-intelligence` `autonomous-agents` `ai-engineering` `agentic-coding` `vibe-coding`
886
+ **Topics:** `ai` `artificial-intelligence` `llm` `claude-code` `cursor` `cline` `kilo-code` `codex` `roo-code` `aider` `opencode` `windsurf` `code-review` `static-analysis` `developer-tools` `npm-package` `typescript` `ollama` `openai` `anthropic` `code-quality` `security-scanner` `health-score` `smart-fix` `vulnerability-scanner` `pattern-learning` `agent-tools` `ai-agent` `code-metrics` `pre-commit-hook` `github-actions` `developer-productivity` `neural-mesh` `quantum-computing` `shannon-entropy` `bayesian-inference` `mcp-server` `model-context-protocol` `semantic-analysis` `dependency-graph` `turboquant` `sssp-algorithm` `genetic-algorithm` `swarm-intelligence` `pagerank` `knowledge-graph` `hallucination-detection` `cross-agent` `self-evolving` `predictive-engine` `ant-colony` `infinite-memory` `vector-compression` `iclr-2026` `arxiv` `super-intelligence` `hyper-intelligence` `autonomous-agents` `ai-engineering` `agentic-coding` `vibe-coding` `cursor-ai` `zero-config` `auto-setup` `dashboard` `plugin-system` `brain-export` `natural-language` `real-time` `websocket` `team-collaboration` `ci-cd` `open-source` `trending` `hierarchical-memory` `context-recall` `consensus-engine` `collective-learning` `infinite-intelligence` `coding-assistant`
677
887
 
678
888
  </div>