mango-brain 3.0.0__tar.gz

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. mango_brain-3.0.0/PKG-INFO +365 -0
  2. mango_brain-3.0.0/README.md +341 -0
  3. mango_brain-3.0.0/mango_brain.egg-info/PKG-INFO +365 -0
  4. mango_brain-3.0.0/mango_brain.egg-info/SOURCES.txt +51 -0
  5. mango_brain-3.0.0/mango_brain.egg-info/dependency_links.txt +1 -0
  6. mango_brain-3.0.0/mango_brain.egg-info/entry_points.txt +2 -0
  7. mango_brain-3.0.0/mango_brain.egg-info/requires.txt +17 -0
  8. mango_brain-3.0.0/mango_brain.egg-info/top_level.txt +1 -0
  9. mango_brain-3.0.0/pyproject.toml +56 -0
  10. mango_brain-3.0.0/server/__init__.py +0 -0
  11. mango_brain-3.0.0/server/__main__.py +4 -0
  12. mango_brain-3.0.0/server/agents/analyzer.md +150 -0
  13. mango_brain-3.0.0/server/agents/executor.md +124 -0
  14. mango_brain-3.0.0/server/agents/mem-manager.md +217 -0
  15. mango_brain-3.0.0/server/agents/verifier.md +213 -0
  16. mango_brain-3.0.0/server/api_routes.py +1083 -0
  17. mango_brain-3.0.0/server/cli.py +462 -0
  18. mango_brain-3.0.0/server/config.py +184 -0
  19. mango_brain-3.0.0/server/dashboard_dist/assets/index-DlCOyfs-.js +88 -0
  20. mango_brain-3.0.0/server/dashboard_dist/assets/index-DukvU8UD.css +2 -0
  21. mango_brain-3.0.0/server/dashboard_dist/favicon.svg +1 -0
  22. mango_brain-3.0.0/server/dashboard_dist/icons.svg +24 -0
  23. mango_brain-3.0.0/server/dashboard_dist/index.html +14 -0
  24. mango_brain-3.0.0/server/database.py +581 -0
  25. mango_brain-3.0.0/server/decay.py +60 -0
  26. mango_brain-3.0.0/server/embeddings.py +79 -0
  27. mango_brain-3.0.0/server/graph.py +162 -0
  28. mango_brain-3.0.0/server/jsonl_parser.py +107 -0
  29. mango_brain-3.0.0/server/main.py +162 -0
  30. mango_brain-3.0.0/server/mangobrain.default.toml +34 -0
  31. mango_brain-3.0.0/server/mcp_tools.py +1358 -0
  32. mango_brain-3.0.0/server/models.py +263 -0
  33. mango_brain-3.0.0/server/prompts/init/01-doc-base.md +282 -0
  34. mango_brain-3.0.0/server/prompts/init/02-code-base.md +296 -0
  35. mango_brain-3.0.0/server/prompts/init/03-event-base.md +201 -0
  36. mango_brain-3.0.0/server/prompts/init/04-chat-base.md +243 -0
  37. mango_brain-3.0.0/server/prompts/init/05-elaborate-base.md +299 -0
  38. mango_brain-3.0.0/server/prompts/reference/memory-definition.md +318 -0
  39. mango_brain-3.0.0/server/retrieval.py +242 -0
  40. mango_brain-3.0.0/server/rules/mangobrain-remember.md +121 -0
  41. mango_brain-3.0.0/server/rules/mangobrain-workflow.md +91 -0
  42. mango_brain-3.0.0/server/skills/discuss/SKILL.md +1183 -0
  43. mango_brain-3.0.0/server/skills/elaborate/SKILL.md +169 -0
  44. mango_brain-3.0.0/server/skills/health-check/SKILL.md +151 -0
  45. mango_brain-3.0.0/server/skills/init/SKILL.md +164 -0
  46. mango_brain-3.0.0/server/skills/memorize/SKILL.md +101 -0
  47. mango_brain-3.0.0/server/skills/smoke-test/SKILL.md +131 -0
  48. mango_brain-3.0.0/server/skills/task/SKILL.md +960 -0
  49. mango_brain-3.0.0/setup.cfg +4 -0
  50. mango_brain-3.0.0/tests/test_core.py +187 -0
  51. mango_brain-3.0.0/tests/test_init.py +149 -0
  52. mango_brain-3.0.0/tests/test_phase2.py +411 -0
  53. mango_brain-3.0.0/tests/test_setup.py +150 -0
@@ -0,0 +1,365 @@
1
+ Metadata-Version: 2.4
2
+ Name: mango-brain
3
+ Version: 3.0.0
4
+ Summary: Persistent associative memory system for Claude Code — complete development workflow
5
+ Author-email: Federico Anastasi <federico.anastasi@outlook.com>
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: fastapi>=0.110
10
+ Requires-Dist: uvicorn>=0.27
11
+ Requires-Dist: mcp>=1.0
12
+ Requires-Dist: sentence-transformers>=2.5
13
+ Requires-Dist: aiosqlite>=0.19
14
+ Requires-Dist: numpy>=1.26
15
+ Requires-Dist: scipy>=1.12
16
+ Requires-Dist: pydantic>=2.6
17
+ Requires-Dist: python-dotenv>=1.0
18
+ Requires-Dist: tiktoken>=0.6
19
+ Provides-Extra: gpu
20
+ Requires-Dist: torch>=2.2; extra == "gpu"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=8.0; extra == "dev"
23
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
24
+
25
+ <p align="center">
26
+ <img src="https://img.shields.io/badge/python-3.11+-blue?style=for-the-badge&logo=python&logoColor=white" />
27
+ <img src="https://img.shields.io/badge/react-19-61DAFB?style=for-the-badge&logo=react&logoColor=black" />
28
+ <img src="https://img.shields.io/badge/MCP-compatible-8A2BE2?style=for-the-badge" />
29
+ <img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge" />
30
+ </p>
31
+
32
+ <h1 align="center">🧠 MangoBrain</h1>
33
+
34
+ <p align="center">
35
+ <strong>A development system for Claude Code where every session learns from the last</strong>
36
+ </p>
37
+
38
+ <p align="center">
39
+ <em>Plan with /discuss. Execute with /task. Knowledge saves itself.</em>
40
+ </p>
41
+
42
+ ---
43
+
44
+ ## The Problem
45
+
46
+ Claude Code forgets everything between sessions. Every new conversation starts from zero — you re-explain architecture, re-discover bugs, re-make decisions. The longer your project lives, the more you repeat yourself.
47
+
48
+ Memory MCP servers exist, but they're just databases. They store and retrieve. You still have to manually decide what to save, when to recall, and how to structure it. The memory doesn't participate in your workflow — it sits next to it.
49
+
50
+ ## How MangoBrain Works
51
+
52
+ MangoBrain is not a memory store. It's a **complete development workflow** that builds memory as a side-effect of doing real work.
53
+
54
+ ```
55
+ /discuss /task automatic
56
+ ┌──────────────┐ ┌───────────────────┐ ┌──────────────────┐
57
+ │ Plan a feature│ │ Execute the plan │ │ mem-manager │
58
+ │ │ │ │ │ saves what you │
59
+ │ Claude starts │─────▶│ analyzer explores │─────▶│ learned, what │
60
+ │ by recalling │ │ with memory │ │ broke, what │
61
+ │ past decisions│ │ executor codes │ │ decisions were │
62
+ │ and known bugs│ │ verifier checks │ │ made — without │
63
+ │ │ │ known issues │ │ you doing │
64
+ │ You plan │ │ │ │ anything │
65
+ │ better. │ │ You ship faster. │ │ Next session │
66
+ │ │ │ │ │ starts smarter. │
67
+ └──────────────┘ └───────────────────┘ └──────────────────┘
68
+ ```
69
+
70
+ **Session 1:** You tell Claude that prices must be stored in cents, not euros.
71
+ **Session 47:** Claude is about to write price logic. The memory surfaces automatically. Claude already knows.
72
+
73
+ **Session 3:** A timezone bug costs you 2 hours debugging.
74
+ **Session 28:** Claude touches date logic. The verifier recalls the timezone gotcha. The bug doesn't happen again.
75
+
76
+ This is the closed loop that no other tool provides: **work → capture → recall → better work**.
77
+
78
+ ---
79
+
80
+ ## How It's Different
81
+
82
+ Most tools give you a piece of the puzzle. MangoBrain is the whole puzzle.
83
+
84
+ | | Memory Store | Workflow Framework | MangoBrain |
85
+ |---|---|---|---|
86
+ | | *Mem0, Official MCP, WhenMoon* | *Ruflo, Claude Pilot, cc-sdd* | |
87
+ | **Remembers across sessions** | ✅ | ❌ or basic | ✅ |
88
+ | **Structured workflow** | ❌ | ✅ | ✅ |
89
+ | **Specialized agents** | ❌ | Some | ✅ 4 agents with strict roles |
90
+ | **Graph relationships** | ❌ | ❌ | ✅ typed edges + propagation |
91
+ | **Temporal decay** | ❌ | ❌ | ✅ episodic/semantic/procedural |
92
+ | **Contradicts & supersedes** | ❌ | ❌ | ✅ outdated info auto-suppressed |
93
+ | **Memory captures automatically** | ❌ | ❌ | ✅ mem-manager at session close |
94
+ | **Memory informs execution** | ❌ | ❌ | ✅ analyzer + verifier query memory |
95
+ | **Health monitoring** | ❌ | ❌ | ✅ dashboard + diagnose + alerts |
96
+
97
+ > **The difference:** other tools give you storage or structure. MangoBrain gives you a system where the *verifier* knows that bug #47 already happened, the *analyzer* starts with architectural context from 30 sessions ago, and the *mem-manager* captures what worked — without you lifting a finger.
98
+
99
+ ---
100
+
101
+ ## The Workflow
102
+
103
+ ### Daily cycle
104
+
105
+ ```
106
+ /discuss ──→ /task ──→ knowledge saved automatically
107
+ │ │ │
108
+ │ │ ▼
109
+ │ │ Next /discuss starts
110
+ │ │ with more context
111
+ │ ▼
112
+ │ 4 specialized agents:
113
+ │ • analyzer (explores code + recalls memory)
114
+ │ • executor (writes code — 100% focused, no memory)
115
+ │ • verifier (QA + checks past known issues)
116
+ │ • mem-manager (saves everything at close)
117
+
118
+
119
+ Produces task.md → fed into /task
120
+ ```
121
+
122
+ ### `/discuss` — Plan with memory
123
+ You describe what you want to build. Claude recalls past decisions, known bugs, architectural patterns. Analyzer agents explore the codebase *and* query memory for relevant gotchas. You plan with full context. Output: a `task.md` ready for execution.
124
+
125
+ ### `/task` — Execute with agents
126
+ Claude reads the task, spawns analyzers (code + memory), creates a plan, then sends executors to write code. The verifier checks the result *and* queries memory for known issues in the areas touched. At close, the mem-manager captures everything learned.
127
+
128
+ ### `/memorize` — Manual save (free sessions)
129
+ For sessions outside the discuss→task cycle. Spawns the mem-manager to extract and save what happened.
130
+
131
+ ### Maintenance
132
+
133
+ | Skill | When | What it does |
134
+ |-------|------|-------------|
135
+ | `/elaborate` | Weekly | Consolidates memory: builds graph edges, finds contradictions, creates abstractions |
136
+ | `/health-check` | Monthly | Diagnoses memory health, finds content gaps, runs targeted fixes |
137
+ | `/smoke-test` | After changes | Tests retrieval quality with 10-20 diverse queries |
138
+
139
+ ---
140
+
141
+ ## Under the Hood
142
+
143
+ The memory engine isn't a simple vector database. It has three layers that work together:
144
+
145
+ <details>
146
+ <summary><strong>🔍 Retrieval — Three modes for different moments</strong></summary>
147
+
148
+ | Mode | Results | Graph | When |
149
+ |------|---------|-------|------|
150
+ | **Deep** | ~20 | Full propagation (α=0.3) | Session start, big picture |
151
+ | **Quick** | ~6 | Light propagation (α=0.15) | Mid-task lookups |
152
+ | **Recent** | ~15 | Time-weighted | WIP context, session resume |
153
+
154
+ The retrieval pipeline: cosine similarity → graph propagation (PageRank-style) → knapsack selection (optimize relevance per token).
155
+
156
+ </details>
157
+
158
+ <details>
159
+ <summary><strong>🕸️ Graph — Memories are connected, not flat</strong></summary>
160
+
161
+ Every memory can relate to others through typed edges:
162
+
163
+ | Edge | Direction | Effect in retrieval |
164
+ |------|-----------|-------------------|
165
+ | `relates_to` | bidirectional | mutual boost |
166
+ | `depends_on` | A → B | A boosts B |
167
+ | `caused_by` | A → B | A boosts B |
168
+ | `co_occurs` | bidirectional | mutual boost |
169
+ | `contradicts` | bidirectional | **suppresses** the weaker one |
170
+ | `supersedes` | A → B | **suppresses** the old version |
171
+
172
+ This means: when a decision is updated, the old version doesn't just sit there confusing Claude — it gets automatically suppressed.
173
+
174
+ </details>
175
+
176
+ <details>
177
+ <summary><strong>⏳ Decay — Not all memories age equally</strong></summary>
178
+
179
+ | Type | Decay rate | Example |
180
+ |------|-----------|---------|
181
+ | **Episodic** | Fast (0.01/day) | "Bug X happened on Tuesday" |
182
+ | **Semantic** | Slow (0.002/day) | "This module uses the strategy pattern" |
183
+ | **Procedural** | Very slow (0.001/day) | "Always use cents, never euros" |
184
+
185
+ Bug reports fade. Architecture decisions persist. Conventions stick around forever.
186
+
187
+ </details>
188
+
189
+ <details>
190
+ <summary><strong>🧩 MCP Tools (14 available)</strong></summary>
191
+
192
+ | Tool | Description |
193
+ |------|-------------|
194
+ | `remember` | Retrieve memories (deep/quick/recent) |
195
+ | `memorize` | Save new memories with embeddings |
196
+ | `update_memory` | Modify content, tags, deprecate |
197
+ | `extract_session` | Parse Claude Code chat JSONL |
198
+ | `prepare_elaboration` | Build working set for elaboration |
199
+ | `apply_elaboration` | Apply elaboration updates |
200
+ | `sync_codebase` | Detect stale/orphan memories |
201
+ | `diagnose` | Health score + prescriptions |
202
+ | `setup_status` | Track initialization progress |
203
+ | `stats` | System statistics |
204
+ | `list_memories` | Search/filter with pagination |
205
+ | `reinforce` | Boost edge weights |
206
+ | `decay` | Apply temporal decay |
207
+ | `init_project` | Bootstrap project metadata |
208
+
209
+ </details>
210
+
211
+ ---
212
+
213
+ ## Dashboard
214
+
215
+ A visual control center with 6 pages:
216
+
217
+ | Page | Purpose |
218
+ |------|---------|
219
+ | **Overview** | Health score, memory growth timeline, setup status, alerts |
220
+ | **Setup** | Step-by-step initialization wizard with progress tracking |
221
+ | **Memories** | Browse, search, filter, inspect individual memories |
222
+ | **Graph** | Force-directed visualization of the memory network |
223
+ | **Monitoring** | Health breakdown, prescriptions, elaboration history |
224
+ | **Guide** | Complete in-app documentation |
225
+
226
+ ---
227
+
228
+ ## Quick Start
229
+
230
+ ### Requirements
231
+
232
+ - **Python** 3.11+
233
+ - **Claude Code** (Anthropic CLI)
234
+
235
+ ### Step 1 — Install
236
+
237
+ ```bash
238
+ pip install mango-brain
239
+ ```
240
+
241
+ ### Step 2 — Set up your project
242
+
243
+ In your project directory:
244
+
245
+ ```bash
246
+ cd /path/to/your/project
247
+ mango-brain install
248
+ ```
249
+
250
+ This will:
251
+ - Detect your GPU and install the right PyTorch (CUDA or CPU)
252
+ - Install skills, agents, rules, and prompts into `.claude/`
253
+ - Configure `.mcp.json` for Claude Code
254
+ - Update `CLAUDE.md` with MangoBrain documentation
255
+ - Register the project in the MangoBrain database
256
+
257
+ ### Step 3 — Open the Dashboard
258
+
259
+ ```bash
260
+ mango-brain serve --api
261
+ ```
262
+
263
+ Go to **http://localhost:3101** — your control center for tracking initialization progress, browsing memories, and monitoring health.
264
+
265
+ ### Step 4 — Restart Claude Code
266
+
267
+ **Close and reopen Claude Code** in your project to load the MangoBrain MCP server.
268
+
269
+ ### Step 5 — Initialize Memory
270
+
271
+ In the new Claude Code session, run:
272
+
273
+ ```
274
+ /init
275
+ ```
276
+
277
+ ### Step 3 — Initialize Memory
278
+
279
+ In the new session, run:
280
+
281
+ ```
282
+ /init
283
+ ```
284
+
285
+ The `/init` wizard guides you through **14 steps across 7 phases**:
286
+
287
+ | Phase | What it does | Sessions |
288
+ |-------|-------------|----------|
289
+ | **1. Doc Base** | Extracts memories from CLAUDE.md, rules, and documentation | 1 |
290
+ | **2. Code Base** | Parallel agents scan the codebase for patterns and architecture | 1-2 |
291
+ | **3. Event Base** | Imports existing knowledge (task lists, project docs) — optional | 1 |
292
+ | **4. Chat Base** | Extracts knowledge from past Claude Code sessions (JSONL) | 1-3 |
293
+ | **5. Elaborate** | Builds the memory graph: edges, contradictions, abstractions | 1-2 |
294
+ | **6. Smoke Test** | 10-20 diverse queries to verify retrieval quality | 1 |
295
+ | **7. Health Check** | Diagnoses gaps, runs targeted fixes, validates final state | 1 |
296
+
297
+ > **Note:** Each phase runs in a separate Claude Code session (for fresh context). The wizard tells you exactly when to restart and what to do next. Progress is tracked automatically — if you stop mid-way, `/init` picks up where you left off. Watch the dashboard update in real-time as memories are created and connected.
298
+
299
+ When the dashboard shows **"Memory Ready"**, initialization is complete.
300
+
301
+ After that, your daily workflow is simply: `/discuss` → `/task` → repeat.
302
+
303
+ ---
304
+
305
+ ## Configuration
306
+
307
+ ```toml
308
+ # mangobrain.toml
309
+
310
+ [embedding]
311
+ model = "auto" # GPU → bge-large (1024d), CPU → bge-base (768d)
312
+ device = "auto" # auto-detects CUDA
313
+
314
+ [retrieval]
315
+ deep_threshold = 0.78
316
+ quick_threshold = 0.85
317
+
318
+ [decay]
319
+ episodic = 0.01 # fast
320
+ semantic = 0.002 # medium
321
+ procedural = 0.001 # slow
322
+ ```
323
+
324
+ ## CLI
325
+
326
+ ```bash
327
+ mango-brain serve # MCP server (stdio)
328
+ mango-brain serve --api # API + dashboard
329
+ mango-brain serve --all # Both
330
+
331
+ mango-brain init -p NAME --path PATH # Initialize project
332
+ mango-brain install --path PATH # Install skills/agents/rules
333
+ mango-brain status -p NAME # Setup progress
334
+ mango-brain doctor # System health check
335
+ mango-brain dashboard # Open dashboard in browser
336
+ ```
337
+
338
+ ## Requirements
339
+
340
+ - **Python** 3.11+
341
+ - **PyTorch** 2.2+ (GPU optional — CPU works fine)
342
+ - **Node.js** 18+ (for dashboard build)
343
+
344
+ ## Project Structure
345
+
346
+ ```
347
+ mangobrain/
348
+ ├── server/ # Python MCP server + REST API
349
+ ├── dashboard/ # React 19 + Vite + Tailwind
350
+ ├── skills/ # 7 skills (/discuss, /task, /init, /memorize, /elaborate, /health-check, /smoke-test)
351
+ ├── agents/ # 4 agent prompts (analyzer, executor, verifier, mem-manager)
352
+ ├── rules/ # 2 auto-loaded rules (query strategy, workflow integration)
353
+ ├── prompts/ # Init phase instructions + memory quality reference
354
+ ├── tests/ # Test suite
355
+ ├── mangobrain.toml # Configuration
356
+ └── pyproject.toml # Python package
357
+ ```
358
+
359
+ ---
360
+
361
+ <p align="center">
362
+ <strong>Built by <a href="https://github.com/Federico-Anastasi">Mango</a></strong>
363
+ <br/>
364
+ <sub>Because your AI pair-programmer shouldn't have amnesia.</sub>
365
+ </p>