@theihtisham/agent-shadow-brain 1.1.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +738 -138
- package/dist/adapters/aider.d.ts +11 -0
- package/dist/adapters/aider.d.ts.map +1 -0
- package/dist/adapters/aider.js +149 -0
- package/dist/adapters/aider.js.map +1 -0
- package/dist/adapters/index.d.ts +3 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +5 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/roo-code.d.ts +14 -0
- package/dist/adapters/roo-code.d.ts.map +1 -0
- package/dist/adapters/roo-code.js +186 -0
- package/dist/adapters/roo-code.js.map +1 -0
- package/dist/brain/adr-engine.d.ts +58 -0
- package/dist/brain/adr-engine.d.ts.map +1 -0
- package/dist/brain/adr-engine.js +400 -0
- package/dist/brain/adr-engine.js.map +1 -0
- package/dist/brain/auto-update.d.ts +9 -0
- package/dist/brain/auto-update.d.ts.map +1 -0
- package/dist/brain/auto-update.js +59 -0
- package/dist/brain/auto-update.js.map +1 -0
- package/dist/brain/code-metrics.d.ts +18 -0
- package/dist/brain/code-metrics.d.ts.map +1 -0
- package/dist/brain/code-metrics.js +224 -0
- package/dist/brain/code-metrics.js.map +1 -0
- package/dist/brain/code-similarity.d.ts +43 -0
- package/dist/brain/code-similarity.d.ts.map +1 -0
- package/dist/brain/code-similarity.js +227 -0
- package/dist/brain/code-similarity.js.map +1 -0
- package/dist/brain/context-completion.d.ts +39 -0
- package/dist/brain/context-completion.d.ts.map +1 -0
- package/dist/brain/context-completion.js +851 -0
- package/dist/brain/context-completion.js.map +1 -0
- package/dist/brain/custom-rules.d.ts +14 -0
- package/dist/brain/custom-rules.d.ts.map +1 -0
- package/dist/brain/custom-rules.js +108 -0
- package/dist/brain/custom-rules.js.map +1 -0
- package/dist/brain/dependency-graph.d.ts +35 -0
- package/dist/brain/dependency-graph.d.ts.map +1 -0
- package/dist/brain/dependency-graph.js +310 -0
- package/dist/brain/dependency-graph.js.map +1 -0
- package/dist/brain/learning-engine.d.ts +54 -0
- package/dist/brain/learning-engine.d.ts.map +1 -0
- package/dist/brain/learning-engine.js +855 -0
- package/dist/brain/learning-engine.js.map +1 -0
- package/dist/brain/mcp-server.d.ts +30 -0
- package/dist/brain/mcp-server.d.ts.map +1 -0
- package/dist/brain/mcp-server.js +408 -0
- package/dist/brain/mcp-server.js.map +1 -0
- package/dist/brain/multi-project.d.ts +13 -0
- package/dist/brain/multi-project.d.ts.map +1 -0
- package/dist/brain/multi-project.js +163 -0
- package/dist/brain/multi-project.js.map +1 -0
- package/dist/brain/neural-mesh.d.ts +69 -0
- package/dist/brain/neural-mesh.d.ts.map +1 -0
- package/dist/brain/neural-mesh.js +677 -0
- package/dist/brain/neural-mesh.js.map +1 -0
- package/dist/brain/notifier.d.ts +26 -0
- package/dist/brain/notifier.d.ts.map +1 -0
- package/dist/brain/notifier.js +151 -0
- package/dist/brain/notifier.js.map +1 -0
- package/dist/brain/orchestrator.d.ts +148 -1
- package/dist/brain/orchestrator.d.ts.map +1 -1
- package/dist/brain/orchestrator.js +428 -0
- package/dist/brain/orchestrator.js.map +1 -1
- package/dist/brain/perf-profiler.d.ts +14 -0
- package/dist/brain/perf-profiler.d.ts.map +1 -0
- package/dist/brain/perf-profiler.js +289 -0
- package/dist/brain/perf-profiler.js.map +1 -0
- package/dist/brain/pr-generator.d.ts +19 -0
- package/dist/brain/pr-generator.d.ts.map +1 -0
- package/dist/brain/pr-generator.js +199 -0
- package/dist/brain/pr-generator.js.map +1 -0
- package/dist/brain/project-config.d.ts +14 -0
- package/dist/brain/project-config.d.ts.map +1 -0
- package/dist/brain/project-config.js +121 -0
- package/dist/brain/project-config.js.map +1 -0
- package/dist/brain/semantic-analyzer.d.ts +46 -0
- package/dist/brain/semantic-analyzer.d.ts.map +1 -0
- package/dist/brain/semantic-analyzer.js +496 -0
- package/dist/brain/semantic-analyzer.js.map +1 -0
- package/dist/brain/team-mode.d.ts +27 -0
- package/dist/brain/team-mode.d.ts.map +1 -0
- package/dist/brain/team-mode.js +262 -0
- package/dist/brain/team-mode.js.map +1 -0
- package/dist/brain/type-safety.d.ts +13 -0
- package/dist/brain/type-safety.d.ts.map +1 -0
- package/dist/brain/type-safety.js +217 -0
- package/dist/brain/type-safety.js.map +1 -0
- package/dist/brain/vuln-scanner.d.ts +16 -0
- package/dist/brain/vuln-scanner.d.ts.map +1 -0
- package/dist/brain/vuln-scanner.js +279 -0
- package/dist/brain/vuln-scanner.js.map +1 -0
- package/dist/cli.js +813 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +320 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +88 -77
package/README.md
CHANGED
|
@@ -1,237 +1,837 @@
|
|
|
1
|
-
# Agent Shadow Brain
|
|
2
|
-
|
|
3
1
|
<div align="center">
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
<img src="banner.svg" alt="Agent Shadow Brain" width="100%">
|
|
6
4
|
|
|
7
5
|
<br/>
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/@theihtisham/agent-shadow-brain)
|
|
8
|
+
[](https://www.npmjs.com/package/@theihtisham/agent-shadow-brain)
|
|
9
|
+
[](https://github.com/theihtisham/agent-shadow-brain/blob/master/LICENSE)
|
|
10
|
+
[](https://nodejs.org/)
|
|
11
|
+
[](https://github.com/theihtisham/agent-shadow-brain/stargazers)
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
[](https://www.npmjs.com/package/@theihtisham/agent-shadow-brain)
|
|
13
|
-
[](https://github.com/theihtisham/agent-shadow-brain/blob/main/LICENSE)
|
|
14
|
-
[](https://www.npmjs.com/package/@theihtisham/agent-shadow-brain)
|
|
15
|
+
### **Mythos-Level Intelligence for AI Coding Agents**
|
|
15
16
|
|
|
16
|
-
**
|
|
17
|
+
No such brain and intelligence has existed before. Shadow Brain is a **super ultra intelligent** real-time intelligence layer powered by Claude Opus 4.6 (or latest model on any agentic AI) that watches your AI coding agents work, applies **mathematically rigorous algorithms** — Shannon entropy, Bayesian inference, cosine similarity, Tarjan's SCC — and injects expert insights back into their memory, making every agent write **better, safer, faster code** across sessions.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
> **Quantum Neural Mesh** — Multiple Shadow Brain instances share knowledge in real-time. What one brain learns, all connected brains know instantly. Cross-session, cross-project, cross-agent superintelligence.
|
|
19
20
|
|
|
20
|
-
[
|
|
21
|
+
[**Getting Started**](#-getting-started) · [**Features**](#-features) · [**Neural Mesh**](#-quantum-neural-mesh) · [**CLI Reference**](#-cli-reference) · [**API**](#-programmatic-api) · [**Architecture**](#-architecture)
|
|
21
22
|
|
|
22
23
|
</div>
|
|
23
24
|
|
|
24
25
|
---
|
|
25
26
|
|
|
26
|
-
##
|
|
27
|
+
## The Problem
|
|
28
|
+
|
|
29
|
+
You use AI coding agents like Claude Code, Cline, Kilo Code, OpenCode, Codex, Roo Code, or Aider. They're powerful, but:
|
|
30
|
+
|
|
31
|
+
- They **repeat the same mistakes** across sessions
|
|
32
|
+
- They **don't learn** from your codebase patterns
|
|
33
|
+
- They **miss security vulnerabilities** in generated code
|
|
34
|
+
- They have **no awareness** of architectural decisions
|
|
35
|
+
- Every session starts from **zero context**
|
|
36
|
+
- Multiple terminals **don't share knowledge** with each other
|
|
37
|
+
|
|
38
|
+
## The Solution
|
|
39
|
+
|
|
40
|
+
**Shadow Brain** runs alongside your agents as a *shadow intelligence layer* with **mythos-level superintelligence**:
|
|
41
|
+
|
|
42
|
+
1. **Watches** every file change and git commit in real-time
|
|
43
|
+
2. **Analyzes** code using LLM-powered review + rule-based engines + mathematical algorithms
|
|
44
|
+
3. **Learns** patterns, correlations, and recurring issues across sessions
|
|
45
|
+
4. **Injects** insights directly into your agent's memory files
|
|
46
|
+
5. **Scores** your codebase health on every change
|
|
47
|
+
6. **Shares** knowledge across all connected Shadow Brain instances via Quantum Neural Mesh
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
┌─────────────┐ watches ┌──────────────┐ injects ┌─────────────┐
|
|
51
|
+
│ AI Agents │ ───────────────▶ │ Shadow Brain │ ─────────────▶ │ AI Agents │
|
|
52
|
+
│ Claude Code │ file changes │ Analyzer │ insights + │ Smarter │
|
|
53
|
+
│ Kilo Code │ git commits │ Health AI │ context + │ Safer │
|
|
54
|
+
│ Cline │ activity │ Pattern Mem │ fixes │ Faster │
|
|
55
|
+
│ OpenCode │ │ Vuln Scan │ │ Connected │
|
|
56
|
+
│ Codex │ │ Smart Fix │ │ │
|
|
57
|
+
│ Roo Code │ │ Neural Mesh │ │ │
|
|
58
|
+
│ Aider │ │ Entropy AI │ │ │
|
|
59
|
+
└─────────────┘ └──────────────┘ └─────────────┘
|
|
60
|
+
▲ ▲
|
|
61
|
+
│ ┌──────────────────────┐ │
|
|
62
|
+
└──────────────│ Quantum Neural Mesh │───────────────────────┘
|
|
63
|
+
shares │ Cross-Session AI │ shares
|
|
64
|
+
knowledge │ Shannon Entropy │ knowledge
|
|
65
|
+
│ Bayesian Inference │
|
|
66
|
+
│ Cosine Similarity │
|
|
67
|
+
└──────────────────────┘
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## ✨ Features
|
|
73
|
+
|
|
74
|
+
<table>
|
|
75
|
+
<tr>
|
|
76
|
+
<td width="50%">
|
|
77
|
+
|
|
78
|
+
### 🧠 Real-Time Intelligence
|
|
79
|
+
- **File watching** — detects changes instantly (chokidar)
|
|
80
|
+
- **Git monitoring** — tracks commits, branches, diffs
|
|
81
|
+
- **LLM-powered analysis** — supports Anthropic, OpenAI, Ollama, OpenRouter
|
|
82
|
+
- **Pattern memory** — learns your codebase patterns over time
|
|
83
|
+
- **Learning engine** — extracts lessons from insights automatically
|
|
84
|
+
|
|
85
|
+
</td>
|
|
86
|
+
<td width="50%">
|
|
87
|
+
|
|
88
|
+
### 🔒 Security & Quality
|
|
89
|
+
- **Vulnerability scanner** — npm audit, pip audit, secrets detection
|
|
90
|
+
- **Custom rules engine** — define your own analysis rules (regex-based)
|
|
91
|
+
- **Framework presets** — auto-detects React, Next.js, Django, FastAPI, etc.
|
|
92
|
+
- **Smart fix engine** — auto-generates fix suggestions with confidence scores
|
|
93
|
+
- **Type safety analyzer** — detects `any`, `@ts-ignore`, missing return types
|
|
94
|
+
|
|
95
|
+
</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td width="50%">
|
|
99
|
+
|
|
100
|
+
### 📊 Health & Metrics
|
|
101
|
+
- **Health scoring** — A-F grading across 6 dimensions
|
|
102
|
+
- **Code metrics** — LOC, complexity, language breakdown, hotspots
|
|
103
|
+
- **SVG badges** — embeddable health score badges
|
|
104
|
+
- **Trend tracking** — health history with persistence
|
|
105
|
+
- **Performance profiler** — N+1 queries, memory leaks, blocking ops
|
|
106
|
+
|
|
107
|
+
</td>
|
|
108
|
+
<td width="50%">
|
|
109
|
+
|
|
110
|
+
### 🔌 Multi-Agent Support (7 Adapters)
|
|
111
|
+
- **Claude Code** — injects into `CLAUDE.md`
|
|
112
|
+
- **Kilo Code** — injects into `.kilocode/rules.md`
|
|
113
|
+
- **Cline** — injects into `.clinerules`
|
|
114
|
+
- **OpenCode** — injects into `AGENT.md`
|
|
115
|
+
- **Codex** — injects into `AGENTS.md`
|
|
116
|
+
- **Roo Code** — injects into `.roo/rules.md`
|
|
117
|
+
- **Aider** — injects into `.aider.conf.yml`
|
|
118
|
+
|
|
119
|
+
</td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td width="50%">
|
|
123
|
+
|
|
124
|
+
### 🚀 Developer Experience
|
|
125
|
+
- **30+ CLI commands** — full control from terminal
|
|
126
|
+
- **MCP Server** — Model Context Protocol for tool integration
|
|
127
|
+
- **Web dashboard** — real-time browser UI at `localhost:7341`
|
|
128
|
+
- **Terminal UI** — Ink/React dashboard in your terminal
|
|
129
|
+
- **Pre-commit hooks** — block bad commits automatically
|
|
130
|
+
- **GitHub Actions** — CI integration with one command
|
|
131
|
+
|
|
132
|
+
</td>
|
|
133
|
+
<td width="50%">
|
|
134
|
+
|
|
135
|
+
### 🌐 Super-Intelligence (v2.0+)
|
|
136
|
+
- **Semantic analyzer** — symbol extraction, unused exports, dead code detection
|
|
137
|
+
- **Dependency graph** — cycles, orphans, hub detection with BFS depth analysis
|
|
138
|
+
- **Code similarity** — duplicate/near-duplicate code detection (Winnowing algorithm)
|
|
139
|
+
- **ADR engine** — Architecture Decision Records, auto-detection from changes
|
|
140
|
+
- **Context completion** — identifies missing docs, configs, knowledge gaps
|
|
141
|
+
- **Multi-project** — watch and compare health across multiple repos
|
|
142
|
+
|
|
143
|
+
</td>
|
|
144
|
+
</tr>
|
|
145
|
+
<tr>
|
|
146
|
+
<td width="50%">
|
|
147
|
+
|
|
148
|
+
### 🔔 Notifications & Reports
|
|
149
|
+
- **Slack / Discord / Webhook** — real-time alerts
|
|
150
|
+
- **HTML reports** — beautiful, shareable analysis reports
|
|
151
|
+
- **Markdown reports** — perfect for PR descriptions
|
|
152
|
+
- **PR description generator** — AI-powered PR body generation
|
|
153
|
+
- **Commit message generator** — conventional commits, auto-generated
|
|
154
|
+
|
|
155
|
+
</td>
|
|
156
|
+
<td width="50%">
|
|
157
|
+
|
|
158
|
+
### 🧬 Team & Mesh
|
|
159
|
+
- **Team mode** — shared insights and patterns across team members
|
|
160
|
+
- **Quantum Neural Mesh** — cross-session intelligence sharing
|
|
161
|
+
- **SSE real-time updates** — Server-Sent Events for live monitoring
|
|
162
|
+
- **Knowledge base** — shared, deduplicated, relevance-scored
|
|
163
|
+
- **Cross-project patterns** — find common issues across your entire portfolio
|
|
164
|
+
|
|
165
|
+
</td>
|
|
166
|
+
</tr>
|
|
167
|
+
</table>
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🌌 Quantum Neural Mesh
|
|
172
|
+
|
|
173
|
+
The Neural Mesh is the breakthrough feature of v2.1.0 — **no such intelligence system has existed before** for AI coding agents. Multiple Shadow Brain instances (running in different terminals, on different projects, with different agents) form a **quantum-entangled neural network** that shares knowledge in real-time.
|
|
174
|
+
|
|
175
|
+
### Mathematical Foundations
|
|
176
|
+
|
|
177
|
+
| Algorithm | Application | Formula |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| **Shannon Entropy** | Relevance scoring for cross-project insights | `H(X) = -Σ p(x) log₂(p(x))` |
|
|
180
|
+
| **Cosine Similarity** | Knowledge deduplication across sessions | `cos(A,B) = (A·B) / (‖A‖·‖B‖)` |
|
|
181
|
+
| **Bayesian Inference** | Confidence updating as evidence accumulates | `P(H\|E) = P(E\|H)·P(H) / P(E)` |
|
|
182
|
+
| **Tarjan's SCC** | Dependency cycle detection | O(V+E) strongly connected components |
|
|
183
|
+
| **BFS Depth Analysis** | Dependency risk scoring | Breadth-first depth = coupling risk |
|
|
184
|
+
| **Winnowing** | Code duplicate fingerprinting | k-gram hashing with window selection |
|
|
185
|
+
|
|
186
|
+
### How It Works
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
Terminal 1 Terminal 2 Terminal 3
|
|
190
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
191
|
+
│ Shadow Brain │ │ Shadow Brain │ │ Shadow Brain │
|
|
192
|
+
│ + Claude │ │ + Cline │ │ + Codex │
|
|
193
|
+
│ + Project A │ │ + Project B │ │ + Project A │
|
|
194
|
+
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
|
|
195
|
+
│ │ │
|
|
196
|
+
└─────────────┬───────────────┘ │
|
|
197
|
+
│ ┌───────────────────────────┘
|
|
198
|
+
▼ ▼
|
|
199
|
+
┌──────────────────────────────┐
|
|
200
|
+
│ Quantum Neural Mesh Bus │
|
|
201
|
+
│ ~/.shadow-brain-mesh/ │
|
|
202
|
+
│ │
|
|
203
|
+
│ • Nodes (heartbeats) │
|
|
204
|
+
│ • Messages (insights) │
|
|
205
|
+
│ • Knowledge (shared) │
|
|
206
|
+
│ │
|
|
207
|
+
│ Entropy: 0.73 │
|
|
208
|
+
│ State: coherent (3 nodes) │
|
|
209
|
+
│ Knowledge: 147 entries │
|
|
210
|
+
└──────────────────────────────┘
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Mesh States
|
|
214
|
+
|
|
215
|
+
| State | Nodes | Description |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| **Coherent** | 3+ | Full quantum coherence — maximum intelligence sharing |
|
|
218
|
+
| **Decoherent** | 1-2 | Partial sharing — limited cross-pollination |
|
|
219
|
+
| **Collapsed** | 0 | Single brain — no mesh connections |
|
|
220
|
+
|
|
221
|
+
### Mesh CLI Commands
|
|
27
222
|
|
|
28
223
|
```bash
|
|
29
|
-
|
|
224
|
+
# View mesh status — nodes, messages, knowledge, quantum state
|
|
225
|
+
shadow-brain mesh status
|
|
226
|
+
|
|
227
|
+
# Get cross-session insights from other brains
|
|
228
|
+
shadow-brain mesh insights
|
|
229
|
+
|
|
230
|
+
# View shared knowledge base
|
|
231
|
+
shadow-brain mesh knowledge
|
|
232
|
+
|
|
233
|
+
# List all connected brain nodes
|
|
234
|
+
shadow-brain mesh nodes
|
|
235
|
+
|
|
236
|
+
# Aggregated analytics across all mesh projects
|
|
237
|
+
shadow-brain mesh aggregate
|
|
30
238
|
```
|
|
31
239
|
|
|
32
|
-
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### 🎭 Brain Personalities
|
|
243
|
+
|
|
244
|
+
Choose how Shadow Brain communicates with your agents:
|
|
245
|
+
|
|
246
|
+
| Personality | Focus | Best For |
|
|
247
|
+
|---|---|---|
|
|
248
|
+
| 🎓 **Mentor** | Teaches & explains patterns | Junior developers, learning |
|
|
249
|
+
| 🔍 **Critic** | Thorough code review | Code quality enforcement |
|
|
250
|
+
| 🏛️ **Architect** | Big-picture design | System design, refactoring |
|
|
251
|
+
| 🛡️ **Security** | Paranoid about vulnerabilities | Security-critical projects |
|
|
252
|
+
| ⚡ **Performance** | Optimization focused | High-performance apps |
|
|
253
|
+
| ⚖️ **Balanced** | All perspectives | Default — recommended |
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 🚀 Getting Started
|
|
258
|
+
|
|
259
|
+
### Install
|
|
33
260
|
|
|
34
261
|
```bash
|
|
35
|
-
|
|
262
|
+
# Install globally
|
|
263
|
+
npm install -g @theihtisham/agent-shadow-brain
|
|
264
|
+
|
|
265
|
+
# Or use with npx (no install)
|
|
266
|
+
npx @theihtisham/agent-shadow-brain review .
|
|
36
267
|
```
|
|
37
268
|
|
|
38
|
-
###
|
|
269
|
+
### One-Command Setup
|
|
39
270
|
|
|
40
271
|
```bash
|
|
41
272
|
shadow-brain setup
|
|
42
273
|
```
|
|
43
274
|
|
|
44
|
-
|
|
275
|
+
Interactive wizard that configures your LLM provider, personality, and review depth.
|
|
45
276
|
|
|
46
|
-
###
|
|
277
|
+
### Start Watching
|
|
47
278
|
|
|
48
279
|
```bash
|
|
49
|
-
shadow-brain
|
|
280
|
+
shadow-brain start .
|
|
50
281
|
```
|
|
51
282
|
|
|
52
|
-
|
|
283
|
+
That's it. Shadow Brain will:
|
|
284
|
+
1. Auto-detect which AI agents are running
|
|
285
|
+
2. Start watching your project files
|
|
286
|
+
3. Analyze every change in real-time
|
|
287
|
+
4. Inject insights into your agent's memory
|
|
288
|
+
5. Connect to the Neural Mesh for cross-session intelligence
|
|
53
289
|
|
|
54
|
-
|
|
290
|
+
### Enable Neural Mesh (Multiple Terminals)
|
|
55
291
|
|
|
56
|
-
|
|
292
|
+
```bash
|
|
293
|
+
# Terminal 1 — Project A with Claude Code
|
|
294
|
+
shadow-brain start ./project-a --mesh
|
|
57
295
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</div>
|
|
296
|
+
# Terminal 2 — Project B with Cline
|
|
297
|
+
shadow-brain start ./project-b --mesh
|
|
61
298
|
|
|
62
|
-
|
|
299
|
+
# Terminal 3 — Check mesh status
|
|
300
|
+
shadow-brain mesh status
|
|
301
|
+
```
|
|
63
302
|
|
|
64
|
-
|
|
303
|
+
What Terminal 1's Shadow Brain learns about security vulnerabilities, Terminal 2 instantly knows too — filtered by relevance using Shannon entropy.
|
|
65
304
|
|
|
66
|
-
###
|
|
305
|
+
### Quick Review (No Watch Mode)
|
|
67
306
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
- **6 brain personalities** — mentor, critic, architect, security, performance, or balanced
|
|
72
|
-
- **Auto-injection** — insights go directly into your agent's memory/rules files
|
|
73
|
-
- **5 agent adapters** — works with Claude Code, Kilo Code, Cline, OpenCode, and Codex
|
|
74
|
-
- **3 review depths** — quick (4K), standard (8K), deep (16K tokens)
|
|
307
|
+
```bash
|
|
308
|
+
# One-shot analysis
|
|
309
|
+
shadow-brain review .
|
|
75
310
|
|
|
76
|
-
|
|
311
|
+
# With health score and fix suggestions
|
|
312
|
+
shadow-brain review . --show-health --show-fixes
|
|
77
313
|
|
|
78
|
-
|
|
314
|
+
# JSON output for scripting
|
|
315
|
+
shadow-brain review . --output json
|
|
316
|
+
```
|
|
79
317
|
|
|
80
|
-
|
|
318
|
+
---
|
|
81
319
|
|
|
82
|
-
|
|
320
|
+
## 📖 CLI Reference
|
|
321
|
+
|
|
322
|
+
### Core Commands
|
|
323
|
+
|
|
324
|
+
| Command | Description |
|
|
325
|
+
|---|---|
|
|
326
|
+
| `shadow-brain start [dir]` | Start watching in real-time |
|
|
327
|
+
| `shadow-brain review [dir]` | One-shot code analysis |
|
|
328
|
+
| `shadow-brain health [dir]` | Compute health score (A-F grading) |
|
|
329
|
+
| `shadow-brain fix [dir]` | Show smart fix suggestions |
|
|
330
|
+
| `shadow-brain report [dir]` | Generate HTML/MD/JSON report |
|
|
331
|
+
| `shadow-brain metrics [dir]` | Code metrics (LOC, complexity, languages) |
|
|
332
|
+
| `shadow-brain scan [dir]` | Vulnerability scanner |
|
|
333
|
+
| `shadow-brain pr [dir]` | Generate PR description |
|
|
334
|
+
| `shadow-brain commit-msg [dir]` | Generate commit message |
|
|
335
|
+
| `shadow-brain ci [dir]` | Generate GitHub Actions workflow |
|
|
336
|
+
| `shadow-brain hook [dir]` | Install pre-commit hook |
|
|
337
|
+
| `shadow-brain rules [dir]` | Manage custom analysis rules |
|
|
338
|
+
| `shadow-brain dash [dir]` | Web dashboard (port 7341) |
|
|
339
|
+
| `shadow-brain inject <msg>` | Manually inject into agent memory |
|
|
340
|
+
| `shadow-brain notify [dir]` | Test notification channels |
|
|
341
|
+
| `shadow-brain status` | Show current configuration |
|
|
342
|
+
| `shadow-brain config` | Manage configuration |
|
|
343
|
+
| `shadow-brain setup` | Interactive setup wizard |
|
|
344
|
+
| `shadow-brain doctor` | Health check & diagnostics |
|
|
345
|
+
|
|
346
|
+
### Super-Intelligence Commands (v2.0+)
|
|
347
|
+
|
|
348
|
+
| Command | Description |
|
|
349
|
+
|---|---|
|
|
350
|
+
| `shadow-brain semantic [dir]` | Semantic analysis — symbols, unused exports, dead code |
|
|
351
|
+
| `shadow-brain deps [dir]` | Dependency graph — cycles, orphans, hubs |
|
|
352
|
+
| `shadow-brain duplicates [dir]` | Detect duplicate/near-duplicate code |
|
|
353
|
+
| `shadow-brain adr [dir]` | Architecture Decision Records |
|
|
354
|
+
| `shadow-brain typesafety [dir]` | TypeScript type safety analysis |
|
|
355
|
+
| `shadow-brain perf [dir]` | Performance profiling |
|
|
356
|
+
| `shadow-brain knowledge [dir]` | Build & view project knowledge base |
|
|
357
|
+
| `shadow-brain gaps [dir]` | Find context gaps (missing docs, configs) |
|
|
358
|
+
| `shadow-brain learn [dir]` | Run learning cycle — extract patterns & lessons |
|
|
359
|
+
| `shadow-brain team share [dir]` | Share insights with team |
|
|
360
|
+
| `shadow-brain team insights` | View team insights |
|
|
361
|
+
| `shadow-brain team stats` | Team activity statistics |
|
|
362
|
+
|
|
363
|
+
### Neural Mesh Commands (v2.1+)
|
|
364
|
+
|
|
365
|
+
| Command | Description |
|
|
366
|
+
|---|---|
|
|
367
|
+
| `shadow-brain mesh status` | View mesh state — nodes, knowledge, quantum state |
|
|
368
|
+
| `shadow-brain mesh insights` | Cross-session insights from other brains |
|
|
369
|
+
| `shadow-brain mesh knowledge` | Shared knowledge base |
|
|
370
|
+
| `shadow-brain mesh nodes` | List all connected brain nodes |
|
|
371
|
+
| `shadow-brain mesh aggregate` | Aggregated cross-project analytics |
|
|
372
|
+
|
|
373
|
+
### Global Options
|
|
83
374
|
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
375
|
+
```
|
|
376
|
+
-p, --provider <provider> LLM provider: anthropic | openai | ollama | openrouter
|
|
377
|
+
-m, --model <model> Model name (e.g., claude-sonnet-4-20250514, gpt-4o, llama3)
|
|
378
|
+
-k, --api-key <key> API key for the provider
|
|
379
|
+
--personality <type> Brain personality: mentor | critic | architect | security | performance | balanced
|
|
380
|
+
--depth <depth> Review depth: quick | standard | deep
|
|
381
|
+
--agents <agents> Comma-separated list of agents to watch
|
|
382
|
+
--no-inject Disable auto-injection
|
|
383
|
+
--mesh Enable Quantum Neural Mesh
|
|
384
|
+
--team <name> Enable team mode with username
|
|
385
|
+
--mcp Start MCP server alongside
|
|
90
386
|
```
|
|
91
387
|
|
|
92
|
-
|
|
93
|
-
|--------|-------------|
|
|
94
|
-
| `-p, --provider` | LLM provider: `anthropic`, `openai`, `ollama`, `openrouter` |
|
|
95
|
-
| `-m, --model` | LLM model name |
|
|
96
|
-
| `-k, --api-key` | API key |
|
|
97
|
-
| `--personality` | Brain personality (see below) |
|
|
98
|
-
| `--depth` | Review depth: `quick`, `standard`, `deep` |
|
|
99
|
-
| `--agents` | Comma-separated agent list |
|
|
100
|
-
| `--no-inject` | Disable auto-injection |
|
|
388
|
+
---
|
|
101
389
|
|
|
102
|
-
|
|
390
|
+
## 💻 Programmatic API
|
|
103
391
|
|
|
104
|
-
|
|
392
|
+
```typescript
|
|
393
|
+
import {
|
|
394
|
+
Orchestrator,
|
|
395
|
+
BrainConfig,
|
|
396
|
+
detectRunningAgents,
|
|
397
|
+
CodeMetricsEngine,
|
|
398
|
+
VulnScanner,
|
|
399
|
+
HealthScoreEngine,
|
|
400
|
+
SmartFixEngine,
|
|
401
|
+
CustomRulesEngine,
|
|
402
|
+
PRGenerator,
|
|
403
|
+
Notifier,
|
|
404
|
+
SemanticAnalyzer,
|
|
405
|
+
DependencyGraphBuilder,
|
|
406
|
+
CodeSimilarityDetector,
|
|
407
|
+
ADREngine,
|
|
408
|
+
TypeSafetyAnalyzer,
|
|
409
|
+
PerformanceProfiler,
|
|
410
|
+
LearningEngine,
|
|
411
|
+
MCPServer,
|
|
412
|
+
TeamMode,
|
|
413
|
+
MultiProjectManager,
|
|
414
|
+
NeuralMesh,
|
|
415
|
+
} from '@theihtisham/agent-shadow-brain';
|
|
416
|
+
|
|
417
|
+
// Create and start the brain
|
|
418
|
+
const config: BrainConfig = {
|
|
419
|
+
provider: 'anthropic',
|
|
420
|
+
projectDir: './my-project',
|
|
421
|
+
agents: ['claude-code', 'cline', 'roo-code'],
|
|
422
|
+
watchMode: true,
|
|
423
|
+
autoInject: true,
|
|
424
|
+
reviewDepth: 'standard',
|
|
425
|
+
brainPersonality: 'balanced',
|
|
426
|
+
};
|
|
105
427
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
428
|
+
const brain = new Orchestrator(config);
|
|
429
|
+
|
|
430
|
+
// Listen to events
|
|
431
|
+
brain.on('insights', ({ insights }) => {
|
|
432
|
+
console.log(`Generated ${insights.length} insights`);
|
|
433
|
+
});
|
|
112
434
|
|
|
113
|
-
|
|
435
|
+
brain.on('health-score', ({ score }) => {
|
|
436
|
+
console.log(`Health: ${score.overall}/100 (${score.grade})`);
|
|
437
|
+
});
|
|
114
438
|
|
|
115
|
-
|
|
439
|
+
brain.on('fixes', ({ fixes }) => {
|
|
440
|
+
console.log(`${fixes.length} fix suggestions available`);
|
|
441
|
+
});
|
|
116
442
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
443
|
+
await brain.start();
|
|
444
|
+
|
|
445
|
+
// ── Super-Intelligence API (v2.0+) ────────────────────────────────────
|
|
446
|
+
|
|
447
|
+
// Semantic analysis
|
|
448
|
+
const semantic = await brain.getSemanticInsights(100);
|
|
449
|
+
console.log(`Found ${semantic.unusedExports.length} unused exports`);
|
|
450
|
+
|
|
451
|
+
// Dependency graph
|
|
452
|
+
const deps = await brain.getDependencyGraph();
|
|
453
|
+
const details = brain.getDependencyDetails(deps);
|
|
454
|
+
console.log(`Cycles: ${details.cycles.length}, Hubs: ${details.hubs.length}`);
|
|
455
|
+
|
|
456
|
+
// Duplicate detection
|
|
457
|
+
const dupes = await brain.detectDuplicates(0.8);
|
|
458
|
+
console.log(`${dupes.length} duplicate groups found`);
|
|
459
|
+
|
|
460
|
+
// Type safety
|
|
461
|
+
const typeIssues = await brain.analyzeTypeSafety();
|
|
462
|
+
console.log(`${typeIssues.length} type safety issues`);
|
|
463
|
+
|
|
464
|
+
// Performance profiling
|
|
465
|
+
const perfInsights = await brain.profilePerformance();
|
|
466
|
+
console.log(`${perfInsights.length} performance suggestions`);
|
|
467
|
+
|
|
468
|
+
// Learning engine
|
|
469
|
+
await brain.runLearningCycle();
|
|
470
|
+
const lessons = await brain.getLearnedLessons();
|
|
471
|
+
|
|
472
|
+
// ── Team Mode ────────────────────────────────────────────────────────
|
|
473
|
+
|
|
474
|
+
brain.enableTeamMode('ihtisham');
|
|
475
|
+
await brain.shareTeamInsight(insights[0]);
|
|
476
|
+
const teamInsights = await brain.getTeamInsights(10);
|
|
477
|
+
|
|
478
|
+
// ── MCP Server ───────────────────────────────────────────────────────
|
|
479
|
+
|
|
480
|
+
await brain.startMCPServer({ port: 7342 });
|
|
481
|
+
// Now accessible via JSON-RPC 2.0 at http://localhost:7342/mcp
|
|
482
|
+
|
|
483
|
+
// ── Neural Mesh (v2.1+) ──────────────────────────────────────────────
|
|
484
|
+
|
|
485
|
+
const mesh = await brain.enableNeuralMesh();
|
|
486
|
+
console.log(`Connected as node ${mesh.getNodeId()}`);
|
|
487
|
+
|
|
488
|
+
// Get cross-session insights from other brains
|
|
489
|
+
const crossInsights = brain.getCrossSessionInsights(20);
|
|
490
|
+
console.log(`${crossInsights.length} relevant insights from other sessions`);
|
|
491
|
+
|
|
492
|
+
// View mesh state
|
|
493
|
+
const state = brain.getMeshState();
|
|
494
|
+
console.log(`Quantum state: ${state?.quantumState}`);
|
|
495
|
+
console.log(`Knowledge entries: ${state?.knowledge.length}`);
|
|
496
|
+
|
|
497
|
+
// Aggregated analytics
|
|
498
|
+
const aggregated = brain.getAggregatedInsights();
|
|
499
|
+
console.log(`Projects: ${aggregated?.totalProjects}, Patterns: ${aggregated?.crossProjectPatterns.length}`);
|
|
500
|
+
|
|
501
|
+
// ── Standard API ─────────────────────────────────────────────────────
|
|
502
|
+
|
|
503
|
+
// Get health score
|
|
504
|
+
const health = await brain.getHealthScore();
|
|
505
|
+
|
|
506
|
+
// Code metrics
|
|
507
|
+
const metrics = await brain.computeMetrics();
|
|
508
|
+
|
|
509
|
+
// Vulnerability scan
|
|
510
|
+
const vulns = await brain.runVulnScan();
|
|
511
|
+
|
|
512
|
+
// Generate PR description
|
|
513
|
+
const pr = await brain.generatePRDescription(changes, 'feature/auth');
|
|
514
|
+
|
|
515
|
+
// Custom rules
|
|
516
|
+
brain.addCustomRule({
|
|
517
|
+
id: 'no-console-log',
|
|
518
|
+
name: 'No Console.Log',
|
|
519
|
+
description: 'Prevent console.log in production code',
|
|
520
|
+
pattern: 'console\\.log\\(',
|
|
521
|
+
severity: 'medium',
|
|
522
|
+
category: 'quality',
|
|
523
|
+
enabled: true,
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// Notifications
|
|
527
|
+
await brain.sendNotification('critical-insight', 'Security Issue', 'Hardcoded API key found');
|
|
121
528
|
```
|
|
122
529
|
|
|
123
|
-
|
|
530
|
+
---
|
|
124
531
|
|
|
125
|
-
|
|
532
|
+
## 🏗️ Architecture
|
|
533
|
+
|
|
534
|
+
### Core Components
|
|
535
|
+
|
|
536
|
+
| Module | File | Purpose |
|
|
537
|
+
|---|---|---|
|
|
538
|
+
| **Orchestrator** | `brain/orchestrator.ts` | Central event loop — coordinates everything |
|
|
539
|
+
| **Analyzer** | `brain/analyzer.ts` | LLM + rule-based code analysis |
|
|
540
|
+
| **LLM Client** | `brain/llm-client.ts` | Multi-provider LLM abstraction (Anthropic, OpenAI, Ollama, OpenRouter) |
|
|
541
|
+
| **Project Context** | `brain/project-context.ts` | Builds project understanding |
|
|
542
|
+
| **Pattern Memory** | `brain/pattern-memory.ts` | Learns codebase patterns |
|
|
543
|
+
| **Health Score** | `brain/health-score.ts` | Multi-dimensional health scoring |
|
|
544
|
+
| **Smart Fix** | `brain/smart-fix.ts` | Auto-generates fix suggestions |
|
|
545
|
+
| **Framework Presets** | `brain/framework-presets.ts` | React, Next.js, Django, FastAPI, etc. |
|
|
546
|
+
| **Custom Rules** | `brain/custom-rules.ts` | User-defined analysis rules |
|
|
547
|
+
| **PR Generator** | `brain/pr-generator.ts` | AI-powered PR/commit messages |
|
|
548
|
+
| **Notifier** | `brain/notifier.ts` | Slack, Discord, Webhook alerts |
|
|
549
|
+
| **Code Metrics** | `brain/code-metrics.ts` | LOC, complexity, language stats |
|
|
550
|
+
| **Vuln Scanner** | `brain/vuln-scanner.ts` | Dependency & secrets scanning |
|
|
551
|
+
| **Report Generator** | `brain/report-generator.ts` | HTML, Markdown, JSON reports |
|
|
552
|
+
| **Auto-Update** | `brain/auto-update.ts` | Version update notifications |
|
|
553
|
+
|
|
554
|
+
### Super-Intelligence Components (v2.0+)
|
|
555
|
+
|
|
556
|
+
| Module | File | Purpose |
|
|
557
|
+
|---|---|---|
|
|
558
|
+
| **Semantic Analyzer** | `brain/semantic-analyzer.ts` | Symbol extraction, unused exports, dead code |
|
|
559
|
+
| **Dependency Graph** | `brain/dependency-graph.ts` | Tarjan's SCC, BFS depth, cycle & hub detection |
|
|
560
|
+
| **Code Similarity** | `brain/code-similarity.ts` | Winnowing algorithm for duplicate detection |
|
|
561
|
+
| **ADR Engine** | `brain/adr-engine.ts` | Architecture Decision Records |
|
|
562
|
+
| **Type Safety** | `brain/type-safety.ts` | `any` detection, `@ts-ignore`, missing types |
|
|
563
|
+
| **Performance Profiler** | `brain/perf-profiler.ts` | N+1 queries, memory leaks, blocking ops |
|
|
564
|
+
| **Context Completion** | `brain/context-completion.ts` | Knowledge gaps, missing docs/configs |
|
|
565
|
+
| **Learning Engine** | `brain/learning-engine.ts` | Pattern extraction, lesson persistence |
|
|
566
|
+
| **MCP Server** | `brain/mcp-server.ts` | JSON-RPC 2.0 MCP protocol server |
|
|
567
|
+
| **Team Mode** | `brain/team-mode.ts` | Shared insights & patterns across team |
|
|
568
|
+
| **Multi-Project** | `brain/multi-project.ts` | Watch multiple repos, aggregate health |
|
|
569
|
+
|
|
570
|
+
### Quantum Neural Mesh (v2.1+)
|
|
571
|
+
|
|
572
|
+
| Module | File | Purpose |
|
|
573
|
+
|---|---|---|
|
|
574
|
+
| **Neural Mesh** | `brain/neural-mesh.ts` | Cross-session shared intelligence |
|
|
575
|
+
| **Entropy Engine** | `brain/neural-mesh.ts` | Shannon entropy relevance scoring |
|
|
576
|
+
| **Knowledge Bus** | `~/.shadow-brain-mesh/` | Filesystem-based knowledge sharing |
|
|
577
|
+
|
|
578
|
+
### Adapter Pattern
|
|
579
|
+
|
|
580
|
+
Each AI agent gets a dedicated adapter that knows how to read its memory files and inject context:
|
|
126
581
|
|
|
127
|
-
|
|
582
|
+
```
|
|
583
|
+
BaseAdapter (abstract)
|
|
584
|
+
├── ClaudeCodeAdapter → CLAUDE.md, .claude/
|
|
585
|
+
├── KiloCodeAdapter → .kilocode/rules.md
|
|
586
|
+
├── ClineAdapter → .clinerules
|
|
587
|
+
├── OpenCodeAdapter → AGENT.md
|
|
588
|
+
├── CodexAdapter → AGENTS.md
|
|
589
|
+
├── RooCodeAdapter → .roo/rules.md
|
|
590
|
+
└── AiderAdapter → .aider.conf.yml
|
|
591
|
+
```
|
|
128
592
|
|
|
129
|
-
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
## 🔧 Configuration
|
|
596
|
+
|
|
597
|
+
### Project Config (`.shadow-brain.json`)
|
|
598
|
+
|
|
599
|
+
```json
|
|
600
|
+
{
|
|
601
|
+
"version": "2.1.0",
|
|
602
|
+
"rules": {
|
|
603
|
+
"customRules": [
|
|
604
|
+
{
|
|
605
|
+
"id": "no-any",
|
|
606
|
+
"name": "No TypeScript Any",
|
|
607
|
+
"description": "Prevent usage of 'any' type",
|
|
608
|
+
"pattern": ":\\s*any\\b",
|
|
609
|
+
"severity": "medium",
|
|
610
|
+
"category": "quality",
|
|
611
|
+
"suggestion": "Use a specific type instead of 'any'",
|
|
612
|
+
"enabled": true
|
|
613
|
+
}
|
|
614
|
+
],
|
|
615
|
+
"ignorePaths": ["**/*.test.ts", "**/*.spec.ts"]
|
|
616
|
+
},
|
|
617
|
+
"notifications": {
|
|
618
|
+
"slack": "https://hooks.slack.com/services/...",
|
|
619
|
+
"discord": "https://discord.com/api/webhooks/...",
|
|
620
|
+
"onHealthDrop": true,
|
|
621
|
+
"onCriticalInsight": true
|
|
622
|
+
},
|
|
623
|
+
"health": {
|
|
624
|
+
"weights": {
|
|
625
|
+
"security": 0.25,
|
|
626
|
+
"performance": 0.15,
|
|
627
|
+
"quality": 0.25,
|
|
628
|
+
"architecture": 0.15,
|
|
629
|
+
"maintainability": 0.10,
|
|
630
|
+
"testCoverage": 0.10
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### Global Config
|
|
130
637
|
|
|
131
638
|
```bash
|
|
639
|
+
# Set LLM provider
|
|
640
|
+
shadow-brain config provider anthropic
|
|
641
|
+
|
|
642
|
+
# Set API key
|
|
643
|
+
shadow-brain config apiKey sk-ant-...
|
|
644
|
+
|
|
645
|
+
# Set brain personality
|
|
646
|
+
shadow-brain config brainPersonality security
|
|
647
|
+
|
|
648
|
+
# View all config
|
|
132
649
|
shadow-brain config --list
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
shadow-brain config personality architect
|
|
650
|
+
|
|
651
|
+
# Reset to defaults
|
|
136
652
|
shadow-brain config --reset
|
|
137
653
|
```
|
|
138
654
|
|
|
139
|
-
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## 🔌 GitHub Actions Integration
|
|
658
|
+
|
|
659
|
+
```bash
|
|
660
|
+
# Generate CI workflow
|
|
661
|
+
shadow-brain ci .
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
Creates `.github/workflows/shadow-brain.yml` that:
|
|
665
|
+
- Runs Shadow Brain analysis on every PR
|
|
666
|
+
- Posts health score as a PR comment
|
|
667
|
+
- Uploads full HTML report as artifact
|
|
668
|
+
- Runs language-specific lint/test jobs
|
|
669
|
+
- Blocks merge on critical issues
|
|
670
|
+
|
|
671
|
+
---
|
|
140
672
|
|
|
141
|
-
|
|
673
|
+
## 🪝 Pre-Commit Hook
|
|
142
674
|
|
|
143
|
-
|
|
675
|
+
```bash
|
|
676
|
+
# Install hook
|
|
677
|
+
shadow-brain hook .
|
|
144
678
|
|
|
145
|
-
|
|
679
|
+
# Remove hook
|
|
680
|
+
shadow-brain hook . --uninstall
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Automatically analyzes your staged changes before each commit. If critical issues are found, the commit is blocked. Bypass with `git commit --no-verify`.
|
|
146
684
|
|
|
147
685
|
---
|
|
148
686
|
|
|
149
|
-
##
|
|
687
|
+
## 📊 Health Score System
|
|
688
|
+
|
|
689
|
+
Shadow Brain computes a multi-dimensional health score (0-100, A-F):
|
|
150
690
|
|
|
151
|
-
|
|
|
152
|
-
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
691
|
+
| Dimension | Weight | What It Checks |
|
|
692
|
+
|---|---|---|
|
|
693
|
+
| 🛡️ Security | 25% | Vulnerabilities, secrets, exposed keys |
|
|
694
|
+
| ✨ Quality | 25% | Code smells, anti-patterns, complexity |
|
|
695
|
+
| ⚡ Performance | 15% | N+1 queries, memory leaks, blocking ops |
|
|
696
|
+
| 🏛️ Architecture | 15% | Coupling, cohesion, dependency health |
|
|
697
|
+
| 🔧 Maintainability | 10% | Code duplication, file sizes, comments |
|
|
698
|
+
| 🧪 Test Coverage | 10% | Test presence, assertion quality |
|
|
699
|
+
|
|
700
|
+
```bash
|
|
701
|
+
# Get health score
|
|
702
|
+
shadow-brain health .
|
|
703
|
+
|
|
704
|
+
# JSON output
|
|
705
|
+
shadow-brain health . --json
|
|
706
|
+
|
|
707
|
+
# SVG badge for README
|
|
708
|
+
shadow-brain health . --badge > health-badge.svg
|
|
709
|
+
```
|
|
158
710
|
|
|
159
711
|
---
|
|
160
712
|
|
|
161
|
-
##
|
|
713
|
+
## 📈 Version History
|
|
714
|
+
|
|
715
|
+
### v2.1.0 — Quantum Neural Mesh
|
|
716
|
+
- **Neural Mesh** — cross-session shared intelligence between multiple Shadow Brain instances
|
|
717
|
+
- **Shannon entropy** relevance scoring for cross-project insight filtering
|
|
718
|
+
- **Cosine similarity** knowledge deduplication with hash-based vectors
|
|
719
|
+
- **Bayesian confidence** updating as evidence accumulates
|
|
720
|
+
- **5 mesh CLI commands** — status, insights, knowledge, nodes, aggregate
|
|
721
|
+
- **Quantum state** tracking — coherent, decoherent, collapsed
|
|
722
|
+
- **Heartbeat & discovery** — automatic node detection with filesystem bus
|
|
723
|
+
|
|
724
|
+
### v2.0.0 — Super-Intelligence Edition
|
|
725
|
+
- **Semantic analyzer** — symbol extraction, unused exports, dead code detection
|
|
726
|
+
- **Dependency graph** — Tarjan's SCC algorithm for cycle detection, BFS depth analysis
|
|
727
|
+
- **Code similarity detector** — Winnowing algorithm for duplicate detection
|
|
728
|
+
- **ADR engine** — Architecture Decision Records, auto-detection from changes
|
|
729
|
+
- **Type safety analyzer** — `any` detection, `@ts-ignore`, missing return types
|
|
730
|
+
- **Performance profiler** — N+1 queries, memory leaks, blocking operations
|
|
731
|
+
- **Context completion** — identifies missing documentation, configs, knowledge gaps
|
|
732
|
+
- **Learning engine** — extracts patterns and lessons from project insights
|
|
733
|
+
- **MCP Server** — JSON-RPC 2.0 Model Context Protocol server
|
|
734
|
+
- **Team mode** — shared insights and patterns across team members
|
|
735
|
+
- **Multi-project** — watch and compare health across multiple repos
|
|
736
|
+
- **Roo Code & Aider adapters** — extended agent coverage
|
|
737
|
+
- **11 new CLI commands** — semantic, deps, duplicates, adr, typesafety, perf, knowledge, gaps, learn, team, mesh
|
|
738
|
+
|
|
739
|
+
### v1.2.0 — Feature Complete
|
|
740
|
+
- **Custom Rules Engine** — define your own analysis rules with regex patterns
|
|
741
|
+
- **PR Description Generator** — AI-powered PR titles and bodies
|
|
742
|
+
- **Commit Message Generator** — conventional commits, auto-generated
|
|
743
|
+
- **Vulnerability Scanner** — npm audit, pip audit, cargo audit, secrets detection
|
|
744
|
+
- **Code Metrics Engine** — LOC, complexity, language breakdown, hotspot detection
|
|
745
|
+
- **Notification System** — Slack, Discord, and webhook alerts for critical findings
|
|
746
|
+
- **Project Config** — `.shadow-brain.json` for per-project settings
|
|
747
|
+
- **Auto-Update Checker** — notifies when a new version is available
|
|
162
748
|
|
|
163
|
-
|
|
164
|
-
<img src="docs/images/personalities.svg" alt="Brain Personalities" width="100%" />
|
|
165
|
-
</div>
|
|
749
|
+
---
|
|
166
750
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
|
170
|
-
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
751
|
+
## 🤝 Supported Agents
|
|
752
|
+
|
|
753
|
+
| Agent | Status | Injection Target |
|
|
754
|
+
|---|---|---|
|
|
755
|
+
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | ✅ Full Support | `CLAUDE.md`, `.claude/` |
|
|
756
|
+
| [Kilo Code](https://kilocode.ai/) | ✅ Full Support | `.kilocode/rules.md` |
|
|
757
|
+
| [Cline](https://github.com/cline/cline) | ✅ Full Support | `.clinerules` |
|
|
758
|
+
| [OpenCode](https://github.com/opencode-ai/opencode) | ✅ Full Support | `AGENT.md` |
|
|
759
|
+
| [Codex](https://github.com/openai/codex) | ✅ Full Support | `AGENTS.md` |
|
|
760
|
+
| [Roo Code](https://roocode.com/) | ✅ Full Support | `.roo/rules.md` |
|
|
761
|
+
| [Aider](https://aider.chat/) | ✅ Full Support | `.aider.conf.yml` |
|
|
762
|
+
| [Cursor](https://cursor.com/) | 🔄 Planned | — |
|
|
175
763
|
|
|
176
764
|
---
|
|
177
765
|
|
|
178
|
-
##
|
|
766
|
+
## 🛠️ Development
|
|
179
767
|
|
|
180
|
-
|
|
768
|
+
```bash
|
|
769
|
+
# Clone
|
|
770
|
+
git clone https://github.com/theihtisham/agent-shadow-brain.git
|
|
771
|
+
cd agent-shadow-brain
|
|
181
772
|
|
|
182
|
-
|
|
773
|
+
# Install dependencies
|
|
774
|
+
npm install
|
|
183
775
|
|
|
184
|
-
|
|
776
|
+
# Build
|
|
777
|
+
npm run build
|
|
185
778
|
|
|
186
|
-
|
|
779
|
+
# Run in dev mode
|
|
780
|
+
npm run dev start .
|
|
187
781
|
|
|
188
|
-
|
|
782
|
+
# Run tests
|
|
783
|
+
npm test
|
|
784
|
+
|
|
785
|
+
# Type check
|
|
786
|
+
npm run lint
|
|
787
|
+
```
|
|
189
788
|
|
|
190
789
|
---
|
|
191
790
|
|
|
192
|
-
##
|
|
791
|
+
## 🗺️ Roadmap
|
|
193
792
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
793
|
+
- [x] ~~**MCP Server Mode** — run as a Model Context Protocol server~~ (v2.0)
|
|
794
|
+
- [x] ~~**Multi-project support** — watch multiple repos simultaneously~~ (v2.0)
|
|
795
|
+
- [x] ~~**Team mode** — shared pattern memory across team members~~ (v2.0)
|
|
796
|
+
- [x] ~~**Roo Code & Aider adapters** — extend agent coverage~~ (v2.0)
|
|
797
|
+
- [x] ~~**Cross-session intelligence** — Neural Mesh quantum sharing~~ (v2.1)
|
|
798
|
+
- [ ] **IDE extensions** — VS Code extension for inline insights
|
|
799
|
+
- [ ] **Custom LLM fine-tuning** — train on your codebase patterns
|
|
800
|
+
- [ ] **Docker image** — one-command containerized deployment
|
|
801
|
+
- [ ] **Web dashboard v2** — React-based interactive analytics dashboard
|
|
802
|
+
- [ ] **Language server** — LSP protocol for real-time inline feedback
|
|
200
803
|
|
|
201
804
|
---
|
|
202
805
|
|
|
203
|
-
##
|
|
806
|
+
## 📄 License
|
|
204
807
|
|
|
205
|
-
|
|
206
|
-
import { Orchestrator, createAdapter, LLMClient, Analyzer, PromptBuilder } from '@theihtisham/agent-shadow-brain';
|
|
808
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
207
809
|
|
|
208
|
-
|
|
209
|
-
provider: 'ollama',
|
|
210
|
-
projectDir: '/path/to/project',
|
|
211
|
-
agents: ['claude-code'],
|
|
212
|
-
watchMode: true,
|
|
213
|
-
autoInject: true,
|
|
214
|
-
reviewDepth: 'standard',
|
|
215
|
-
brainPersonality: 'balanced',
|
|
216
|
-
});
|
|
810
|
+
---
|
|
217
811
|
|
|
218
|
-
|
|
219
|
-
console.log('Generated insights:', insights);
|
|
220
|
-
});
|
|
812
|
+
## 👤 Author
|
|
221
813
|
|
|
222
|
-
|
|
223
|
-
|
|
814
|
+
**theihtisham**
|
|
815
|
+
|
|
816
|
+
[](https://github.com/theihtisham)
|
|
817
|
+
[](https://www.npmjs.com/~theihtisham)
|
|
224
818
|
|
|
225
819
|
---
|
|
226
820
|
|
|
227
|
-
|
|
821
|
+
<div align="center">
|
|
822
|
+
|
|
823
|
+
### If Shadow Brain makes your AI agents smarter, give it a ⭐
|
|
824
|
+
|
|
825
|
+
[](https://star-history.com/#theihtisham/agent-shadow-brain&Date)
|
|
228
826
|
|
|
229
|
-
|
|
230
|
-
2. Create your feature branch: `git checkout -b feature/my-feature`
|
|
231
|
-
3. Commit your changes: `git commit -m 'Add my feature'`
|
|
232
|
-
4. Push to the branch: `git push origin feature/my-feature`
|
|
233
|
-
5. Open a Pull Request
|
|
827
|
+
**Built with 🧠 by [theihtisham](https://github.com/theihtisham)**
|
|
234
828
|
|
|
235
|
-
|
|
829
|
+
</div>
|
|
830
|
+
|
|
831
|
+
---
|
|
236
832
|
|
|
237
|
-
|
|
833
|
+
<div align="center">
|
|
834
|
+
|
|
835
|
+
**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` `shadow-ai` `neural-code-review` `auto-review` `intelligence-layer` `multi-agent` `ai-coding-assistant` `devtools` `cli-tool` `code-analysis` `software-quality` `tech-debt` `ai-tools` `prompt-engineering` `agentic-coding` `vibe-coding` `ai-engineering` `llm-tools` `ai-workflow` `code-intelligence` `neural-mesh` `quantum-computing` `shannon-entropy` `bayesian-inference` `mcp-server` `semantic-analysis` `dependency-graph` `team-collaboration` `cross-session` `super-intelligence`
|
|
836
|
+
|
|
837
|
+
</div>
|