nexo-brain 0.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +241 -0
  3. package/bin/create-nexo.js +593 -0
  4. package/package.json +32 -0
  5. package/scripts/pre-commit-check.sh +55 -0
  6. package/src/cognitive.py +1224 -0
  7. package/src/db.py +2283 -0
  8. package/src/hooks/caffeinate-guard.sh +8 -0
  9. package/src/hooks/capture-session.sh +19 -0
  10. package/src/hooks/session-start.sh +27 -0
  11. package/src/hooks/session-stop.sh +11 -0
  12. package/src/plugin_loader.py +136 -0
  13. package/src/plugins/__init__.py +0 -0
  14. package/src/plugins/agents.py +52 -0
  15. package/src/plugins/backup.py +103 -0
  16. package/src/plugins/cognitive_memory.py +305 -0
  17. package/src/plugins/entities.py +61 -0
  18. package/src/plugins/episodic_memory.py +391 -0
  19. package/src/plugins/evolution.py +113 -0
  20. package/src/plugins/guard.py +346 -0
  21. package/src/plugins/preferences.py +47 -0
  22. package/src/scripts/nexo-auto-update.py +213 -0
  23. package/src/scripts/nexo-catchup.py +179 -0
  24. package/src/scripts/nexo-cognitive-decay.py +82 -0
  25. package/src/scripts/nexo-daily-self-audit.py +532 -0
  26. package/src/scripts/nexo-postmortem-consolidator.py +594 -0
  27. package/src/scripts/nexo-sleep.py +762 -0
  28. package/src/scripts/nexo-synthesis.py +537 -0
  29. package/src/server.py +560 -0
  30. package/src/tools_coordination.py +102 -0
  31. package/src/tools_credentials.py +64 -0
  32. package/src/tools_learnings.py +180 -0
  33. package/src/tools_menu.py +208 -0
  34. package/src/tools_reminders.py +80 -0
  35. package/src/tools_reminders_crud.py +157 -0
  36. package/src/tools_sessions.py +169 -0
  37. package/src/tools_task_history.py +57 -0
  38. package/templates/CLAUDE.md.template +89 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WAzion Apps
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ # NEXO — Your Claude Code Gets a Brain
2
+
3
+ **NEXO transforms Claude Code from a stateless assistant into a cognitive partner that remembers, learns, forgets, adapts, and builds a relationship with you over time.**
4
+
5
+ Every time you close a Claude Code session, everything is lost. Your assistant doesn't remember yesterday's decisions, repeats the same mistakes, and starts from zero. NEXO fixes this by giving Claude Code a brain — modeled after how human memory actually works.
6
+
7
+ ## The Problem
8
+
9
+ Claude Code is powerful but amnesic:
10
+ - **No memory** — closes a session, forgets everything
11
+ - **Repeats mistakes** — makes the same error you corrected yesterday
12
+ - **No context** — can't connect today's work with last week's decisions
13
+ - **Reactive** — waits for instructions instead of anticipating needs
14
+ - **No learning** — doesn't improve from experience
15
+
16
+ ## The Solution: A Cognitive Architecture
17
+
18
+ NEXO implements the **Atkinson-Shiffrin memory model** from cognitive psychology (1968) — the same model that explains how human memory works:
19
+
20
+ ```
21
+ What you say and do
22
+
23
+ ├─→ Sensory Register (raw capture, 48h)
24
+ │ │
25
+ │ └─→ Attention filter: "Is this worth remembering?"
26
+ │ │
27
+ │ ↓
28
+ ├─→ Short-Term Memory (7-day half-life)
29
+ │ │
30
+ │ ├─→ Used often? → Consolidate to Long-Term Memory
31
+ │ └─→ Not accessed? → Gradually forgotten
32
+
33
+ └─→ Long-Term Memory (60-day half-life)
34
+
35
+ ├─→ Active: instantly searchable by meaning
36
+ ├─→ Dormant: faded but recoverable ("oh right, I remember now!")
37
+ └─→ Near-duplicates auto-merged to prevent clutter
38
+ ```
39
+
40
+ This isn't a metaphor. NEXO literally implements Ebbinghaus forgetting curves, rehearsal-based reinforcement, and memory consolidation during automated "sleep" processes.
41
+
42
+ ## What Makes NEXO Different
43
+
44
+ | Without NEXO | With NEXO |
45
+ |-------------|-----------|
46
+ | Memory gone after each session | Persistent across sessions with natural decay and reinforcement |
47
+ | Repeats the same mistakes | Checks "have I made this mistake before?" before every action |
48
+ | Keyword search only | Finds memories by **meaning**, not just words |
49
+ | Starts cold every time | Resumes from the mental state of the last session |
50
+ | Same behavior regardless of context | Adapts tone and approach based on your mood |
51
+ | No relationship | Trust score that evolves — makes fewer redundant checks as alignment grows |
52
+
53
+ ## How the Brain Works
54
+
55
+ ### Memory That Forgets (And That's a Feature)
56
+
57
+ NEXO uses **Ebbinghaus forgetting curves** — memories naturally fade over time unless reinforced by use. This isn't a bug, it's how useful memory works:
58
+
59
+ - A lesson learned yesterday is strong. If you never encounter it again, it fades — because it probably wasn't important.
60
+ - A lesson accessed 5 times in 2 weeks gets promoted to long-term memory — because repeated use proves it matters.
61
+ - A dormant memory can be reactivated if something similar comes up — the "oh wait, I remember this" moment.
62
+
63
+ ### Semantic Search (Finding by Meaning)
64
+
65
+ NEXO doesn't search by keywords. It searches by **meaning** using vector embeddings (fastembed, 384 dimensions).
66
+
67
+ Example: If you search for "deploy problems", NEXO will find a memory about "SSH connection timeout on production server" — even though they share zero words. This is how human associative memory works.
68
+
69
+ ### Metacognition (Thinking About Thinking)
70
+
71
+ Before every code change, NEXO asks itself: **"Have I made a mistake like this before?"**
72
+
73
+ It searches its memory for related errors, warnings, and lessons learned. If it finds something relevant, it surfaces the warning BEFORE acting — not after you've already broken production.
74
+
75
+ ### Cognitive Dissonance
76
+
77
+ When you give an instruction that contradicts NEXO's established knowledge, it doesn't silently obey or silently resist. It **verbalizes the conflict**:
78
+
79
+ > "My memory says you prefer Tailwind over plain CSS, but you're asking me to write inline styles. Is this a permanent change or a one-time exception?"
80
+
81
+ You decide: **paradigm shift** (permanent change), **exception** (one-time), or **override** (old memory was wrong).
82
+
83
+ ### Sibling Memories
84
+
85
+ Some memories look identical but apply to different contexts. "How to deploy" for Project A is different from Project B. NEXO detects discriminating entities (different OS, platform, language) and links them as **siblings** instead of merging them:
86
+
87
+ > "Applying the Linux deploy procedure. Note: there's a sibling for macOS that uses a different port."
88
+
89
+ ### Trust Score (0-100)
90
+
91
+ NEXO tracks alignment with you through a trust score:
92
+
93
+ - **You say thanks** → score goes up → NEXO reduces redundant verification checks
94
+ - **NEXO makes a mistake you already taught it** → score drops → NEXO becomes more careful, checks more thoroughly
95
+ - **The score doesn't control permissions** — you're always in control. It's a mirror that helps NEXO calibrate its own rigor.
96
+
97
+ ### Sentiment Detection
98
+
99
+ NEXO reads your tone (keywords, message length, urgency signals) and adapts:
100
+
101
+ - **Frustrated?** → Ultra-concise mode. Zero explanations. Just solve the problem.
102
+ - **In flow?** → Good moment to suggest that backlog item from last Tuesday.
103
+ - **Urgent?** → Immediate action, no preamble.
104
+
105
+ ### Sleep Cycle
106
+
107
+ Like a human brain, NEXO has automated processes that run while you're not using it:
108
+
109
+ | Time | Process | Human Analogy |
110
+ |------|---------|---------------|
111
+ | 03:00 | Decay + memory consolidation + merge duplicates | Deep sleep consolidation |
112
+ | 04:00 | Clean expired data, prune redundant memories | Synaptic pruning |
113
+ | 07:00 | Self-audit, health checks, metrics | Waking up + orientation |
114
+ | 23:30 | Process day's events, extract patterns | Pre-sleep reflection |
115
+ | Boot | Catch-up: run anything missed while computer was off | — |
116
+
117
+ If your Mac was asleep during any scheduled process, NEXO catches up in order when it wakes.
118
+
119
+ ## Quick Start
120
+
121
+ ```bash
122
+ npx nexo-brain
123
+ ```
124
+
125
+ The installer handles everything:
126
+
127
+ ```
128
+ How should I call myself? (default: NEXO) > Atlas
129
+
130
+ Can I explore your workspace to learn about your projects? (y/n) > y
131
+
132
+ Keep Mac awake so my cognitive processes run on schedule? (y/n) > y
133
+
134
+ Installing cognitive engine dependencies...
135
+ Setting up NEXO home...
136
+ Scanning workspace...
137
+ - 3 git repositories
138
+ - Node.js project detected
139
+ Configuring Claude Code MCP server...
140
+ Setting up automated processes...
141
+ 5 automated processes configured.
142
+ Caffeinate enabled.
143
+ Generating operator instructions...
144
+
145
+ ╔══════════════════════════════════════════════════════════╗
146
+ ║ Atlas is ready. ║
147
+ ║ Open Claude Code and start a conversation. ║
148
+ ╚══════════════════════════════════════════════════════════╝
149
+ ```
150
+
151
+ Open Claude Code and start working. Atlas will introduce itself on the first message.
152
+
153
+ ### What Gets Installed
154
+
155
+ | Component | What | Where |
156
+ |-----------|------|-------|
157
+ | Cognitive engine | Python: fastembed, numpy, vector search | pip packages |
158
+ | MCP server | 50+ tools for memory, learning, guard | ~/.nexo/ |
159
+ | Plugins | Guard, episodic memory, cognitive memory, entities, preferences | ~/.nexo/plugins/ |
160
+ | Hooks | Session capture, briefing, stop detection | ~/.nexo/hooks/ |
161
+ | LaunchAgents | Decay, sleep, audit, postmortem, catch-up | ~/Library/LaunchAgents/ |
162
+ | Auto-update | Checks for new versions at boot | Built into catch-up |
163
+ | Claude Code config | MCP server + hooks registered | ~/.claude/settings.json |
164
+
165
+ ### Requirements
166
+
167
+ - **macOS** (Linux support planned)
168
+ - **Node.js 18+** (for the installer)
169
+ - Python 3, Homebrew, and Claude Code are installed automatically if missing.
170
+
171
+ ## Architecture
172
+
173
+ ### 50+ MCP Tools
174
+
175
+ | Category | Tools | Purpose |
176
+ |----------|-------|---------|
177
+ | Cognitive (8) | retrieve, stats, inspect, metrics, dissonance, resolve, sentiment, trust | The brain |
178
+ | Guard (3) | check, stats, log_repetition | Error prevention |
179
+ | Episodic (10) | changes, decisions, session diary, recall | What happened and why |
180
+ | Sessions (3) | startup, heartbeat, status | Session lifecycle |
181
+ | Reminders (4) | create, update, complete, delete | User's tasks |
182
+ | Followups (4) | create, update, complete, delete | System's tasks |
183
+ | Learnings (5) | add, search, update, delete, list | Error patterns |
184
+ | Entities (5) | search, create, update, delete, list | People, services, URLs |
185
+ | Preferences (4) | get, set, list, delete | Observed preferences |
186
+ | Credentials (5) | create, get, update, delete, list | Secure storage |
187
+ | Agents (5) | get, create, update, delete, list | Agent delegation |
188
+ | Backup (3) | now, list, restore | Data safety |
189
+ | Evolution (5) | propose, approve, reject, status, history | Self-improvement |
190
+
191
+ ### Plugin System
192
+
193
+ NEXO supports hot-loadable plugins. Drop a `.py` file in `~/.nexo/plugins/`:
194
+
195
+ ```python
196
+ # my_plugin.py
197
+ def handle_my_tool(query: str) -> str:
198
+ """My custom tool description."""
199
+ return f"Result for {query}"
200
+
201
+ TOOLS = [
202
+ (handle_my_tool, "nexo_my_tool", "Short description"),
203
+ ]
204
+ ```
205
+
206
+ Reload without restarting: `nexo_plugin_load("my_plugin.py")`
207
+
208
+ ### Data Privacy
209
+
210
+ - **Everything stays local.** All data in `~/.nexo/`, never uploaded anywhere.
211
+ - **No telemetry.** No analytics. No phone-home.
212
+ - **No cloud dependencies.** Vector search runs on CPU (fastembed), not an API.
213
+ - **Auto-update is opt-in.** Checks GitHub releases, never sends data.
214
+
215
+ ## The Psychology Behind NEXO
216
+
217
+ NEXO isn't just engineering — it's applied cognitive psychology:
218
+
219
+ | Psychological Concept | How NEXO Implements It |
220
+ |----------------------|----------------------|
221
+ | Atkinson-Shiffrin (1968) | Three memory stores: sensory register → STM → LTM |
222
+ | Ebbinghaus Forgetting Curve (1885) | Exponential decay: `strength = strength × e^(-λ × time)` |
223
+ | Rehearsal Effect | Accessing a memory resets its strength to 1.0 |
224
+ | Memory Consolidation | Nightly process promotes frequently-used STM to LTM |
225
+ | Metacognition | Guard system checks past errors before acting |
226
+ | Cognitive Dissonance | Detects and verbalizes conflicts between old and new knowledge |
227
+ | Theory of Mind | Models user behavior, preferences, and mood |
228
+ | Synaptic Pruning | Automated cleanup of weak, unused memories |
229
+ | Associative Memory | Semantic search finds related concepts, not just matching words |
230
+
231
+ ## Contributing
232
+
233
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Issues and PRs welcome.
234
+
235
+ ## License
236
+
237
+ MIT — see [LICENSE](LICENSE)
238
+
239
+ ---
240
+
241
+ Built by [WAzion](https://wazion.com) | Created by Francisco Garcia