nexo-brain 2.6.4 → 2.6.5

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 CHANGED
@@ -1,942 +1,220 @@
1
- # NEXO Brain — Your AI Gets a Brain
1
+ # NEXO Brain
2
2
 
3
- [![npm](https://img.shields.io/npm/v/nexo-brain?label=npm&color=purple)](https://www.npmjs.com/package/nexo-brain)
4
- [![F1 0.588 on LoCoMo](https://img.shields.io/badge/LoCoMo_F1-0.588-brightgreen)](https://github.com/wazionapps/nexo/blob/main/benchmarks/locomo/results/)
5
- [![+55% vs GPT-4](https://img.shields.io/badge/vs_GPT--4-%2B55%25-blue)](https://github.com/snap-research/locomo/issues/33)
3
+ [![npm](https://img.shields.io/npm/v/nexo-brain?label=npm&color=7C3AED)](https://www.npmjs.com/package/nexo-brain)
4
+ [![LoCoMo F1 0.588](https://img.shields.io/badge/LoCoMo_F1-0.588-22C55E)](https://github.com/wazionapps/nexo/tree/main/benchmarks/locomo)
5
+ [![vs GPT-4](https://img.shields.io/badge/vs_GPT--4-%2B55%25-2563EB)](https://github.com/snap-research/locomo/issues/33)
6
+ [![License: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-0F172A)](LICENSE)
6
7
  [![GitHub stars](https://img.shields.io/github/stars/wazionapps/nexo?style=social)](https://github.com/wazionapps/nexo/stargazers)
7
- [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
8
8
 
9
- > The first AI memory system with architectural inhibitory control — the agent reasons about whether to act before acting. Cognitive Cortex, Context Continuity via auto-compaction hooks, Smart Startup, Context Packets, Auto-Prime, 30 Core Rules as DNA, auto-update, auto-diary, CLAUDE.md version tracker, personal scripts registry, and Claude Code plugin structure. Battle-tested from 6 months of production use, validated via multi-AI debate.
9
+ > Give Claude Code a long-term memory, a runtime, and a recovery loop.
10
10
 
11
- **NEXO Brain transforms any MCP-compatible AI agent from a stateless assistant into a cognitive partner that remembers, learns, forgets, adapts, and builds a relationship with you over time.**
11
+ NEXO Brain is a local cognitive runtime for Claude Code and other MCP clients. It gives your agent persistent memory, overnight learning, startup preflight, doctor diagnostics, recovery-aware background jobs, personal scripts, and wake catch-up so work survives across sessions and across sleep.
12
12
 
13
13
  <p align="center">
14
14
  <a href="https://www.youtube.com/watch?v=IBs7zh7ZMG0">
15
- <img src="assets/nexo-brain-infographic-v5.png" alt="NEXO Brain Architecture" width="700">
15
+ <img src="assets/nexo-brain-infographic-v5.png" alt="NEXO Brain overview" width="880">
16
16
  </a>
17
17
  </p>
18
18
 
19
- [Watch the overview on YouTube](https://www.youtube.com/watch?v=IBs7zh7ZMG0) · [Watch the full deep-dive](https://www.youtube.com/watch?v=bKAfowyyy5M)
20
-
21
- Every time you close a session, everything is lost. Your agent doesn't remember yesterday's decisions, repeats the same mistakes, and starts from zero. NEXO Brain fixes this with a cognitive architecture modeled after how human memory actually works.
22
-
23
- ## The Problem
24
-
25
- AI coding agents are powerful but amnesic:
26
- - **No memory** — closes a session, forgets everything
27
- - **Repeats mistakes** — makes the same error you corrected yesterday
28
- - **No context** — can't connect today's work with last week's decisions
29
- - **Reactive** — waits for instructions instead of anticipating needs
30
- - **No learning** — doesn't improve from experience
31
- - **No safety** — stores anything it's told, including poisoned or redundant data
32
-
33
- ## The Solution: A Cognitive Architecture
34
-
35
- NEXO Brain implements the **Atkinson-Shiffrin memory model** from cognitive psychology (1968) — the same model that explains how human memory works:
36
-
37
- ```
38
- What you say and do
39
- |
40
- +---> Sensory Register (raw capture, 48h)
41
- | |
42
- | +---> Attention filter: "Is this worth remembering?"
43
- | |
44
- | v
45
- +---> Short-Term Memory (7-day half-life)
46
- | |
47
- | +---> Used often? --> Consolidate to Long-Term Memory
48
- | +---> Not accessed? --> Gradually forgotten
49
- |
50
- +---> Long-Term Memory (60-day half-life)
51
- |
52
- +---> Active: instantly searchable by meaning
53
- +---> Dormant: faded but recoverable ("oh right, I remember now!")
54
- +---> Near-duplicates auto-merged to prevent clutter
55
- ```
56
-
57
- This isn't a metaphor. NEXO Brain literally implements Ebbinghaus forgetting curves, rehearsal-based reinforcement, and memory consolidation during automated "sleep" processes.
58
-
59
- ## What Makes NEXO Brain Different
60
-
61
- | Without NEXO Brain | With NEXO Brain |
62
- |---------------------|-----------------|
63
- | Memory gone after each session | Persistent across sessions with natural decay and reinforcement |
64
- | Repeats the same mistakes | Checks "have I made this mistake before?" before every action |
65
- | Keyword search only | Finds memories by **meaning**, not just words |
66
- | Starts cold every time | Resumes from the mental state of the last session |
67
- | Same behavior regardless of context | Adapts tone and approach based on your mood |
68
- | No relationship | Trust score that evolves — makes fewer redundant checks as alignment grows |
69
- | Stores everything blindly | Prediction error gating rejects redundant information at write time |
70
- | Vulnerable to memory poisoning | 4-layer security pipeline scans every memory before storage |
71
- | No proactive behavior | Context-triggered reminders fire when topics match, not just by date |
72
-
73
- ## How the Brain Works
74
-
75
- ### Memory That Forgets (And That's a Feature)
76
-
77
- NEXO Brain uses **Ebbinghaus forgetting curves** — memories naturally fade over time unless reinforced by use. This isn't a bug, it's how useful memory works:
78
-
79
- - A lesson learned yesterday is strong. If you never encounter it again, it fades — because it probably wasn't important.
80
- - A lesson accessed 5 times in 2 weeks gets promoted to long-term memory — because repeated use proves it matters.
81
- - A dormant memory can be reactivated if something similar comes up — the "oh wait, I remember this" moment.
82
-
83
- ### Semantic Search (Finding by Meaning)
84
-
85
- NEXO Brain doesn't search by keywords. It searches by **meaning** using vector embeddings (fastembed, 768 dimensions).
86
-
87
- Example: If you search for "deploy problems", NEXO Brain will find a memory about "SSH connection timeout on production server" — even though they share zero words. This is how human associative memory works.
88
-
89
- ### Metacognition (Thinking About Thinking)
90
-
91
- Before every code change, NEXO Brain asks itself: **"Have I made a mistake like this before?"**
92
-
93
- 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.
94
-
95
- ### Cognitive Dissonance
96
-
97
- When you give an instruction that contradicts established knowledge, NEXO Brain doesn't silently obey or silently resist. It **verbalizes the conflict**:
98
-
99
- > "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?"
100
-
101
- You decide: **paradigm shift** (permanent change), **exception** (one-time), or **override** (old memory was wrong).
102
-
103
- ### Sibling Memories
104
-
105
- Some memories look identical but apply to different contexts. "How to deploy" for Project A is different from Project B. NEXO Brain detects discriminating entities (different OS, platform, language) and links them as **siblings** instead of merging them:
106
-
107
- > "Applying the Linux deploy procedure. Note: there's a sibling for macOS that uses a different port."
108
-
109
- ### Trust Score (0-100)
110
-
111
- NEXO Brain tracks alignment with you through a trust score:
112
-
113
- - **You say thanks** --> score goes up --> reduces redundant verification checks
114
- - **Makes a mistake you already taught it** --> score drops --> becomes more careful, checks more thoroughly
115
- - **The score doesn't control permissions** — you're always in control. It's a mirror that helps calibrate rigor.
116
-
117
- ### Sentiment Detection
118
-
119
- NEXO Brain reads your tone (keywords, message length, urgency signals) and adapts:
120
-
121
- - **Frustrated?** --> Ultra-concise mode. Zero explanations. Just solve the problem.
122
- - **In flow?** --> Good moment to suggest that backlog item from last Tuesday.
123
- - **Urgent?** --> Immediate action, no preamble.
124
-
125
- ### Sleep Cycle
126
-
127
- Like a human brain, NEXO Brain has automated processes that run while you're not using it:
128
-
129
- | Time | Process | Human Analogy |
130
- |------|---------|---------------|
131
- | 03:00 | Decay + memory consolidation + merge duplicates + dreaming | Deep sleep consolidation |
132
- | 04:00 | Clean expired data, prune redundant memories | Synaptic pruning |
133
- | 07:00 | Self-audit, health checks, metrics | Waking up + orientation |
134
- | 23:30 | Process day's events, extract patterns | Pre-sleep reflection |
135
- | Boot | Catch-up: run anything missed while computer was off | -- |
136
-
137
- If your Mac was asleep during any scheduled process, NEXO Brain catches up in order when it wakes.
138
-
139
- ## Cognitive Cortex
140
-
141
- The Cortex is a middleware cognitive layer that makes the agent **think before acting**. It implements architectural inhibitory control — the agent cannot bypass reasoning.
142
-
143
- ```
144
- User message → Fast Path check → Simple chat? → Respond directly
145
- → Action needed? → Cortex activates
146
-
147
- Generate cognitive state
148
- (goal, plan, unknowns, evidence)
149
-
150
- Middleware validates
151
- ├─ Unknowns? → ASK mode (tools blocked)
152
- ├─ No plan? → PROPOSE mode (read-only)
153
- └─ Plan + evidence → ACT mode (full access)
154
- ```
155
-
156
- | Feature | What It Does |
157
- |---------|-------------|
158
- | **Inhibitory Control** | Physically restricts tools based on reasoning quality. Unknowns → can only ask. No plan → can only propose. Evidence + verification → can act. |
159
- | **Event-Driven Activation** | Only activates on tool intent, ambiguity, destructive actions, or retries. Simple chat has zero overhead. |
160
- | **Trust-Gated Escalation** | Low trust score → requires more evidence before allowing "act" mode. Trust builds through successful execution. |
161
- | **Core Rules Injection** | Automatically surfaces relevant behavioral rules based on task type. |
162
- | **Activation Metrics** | Tracks modes, inhibition rates, and task types for continuous improvement. |
163
-
164
- The Cortex was designed through a 3-way AI debate (Claude Opus 4.6 + GPT-5.4 + Gemini 3.1 Pro) and validated against 6 months of real production failures.
165
-
166
- ## Context Continuity (Auto-Compaction)
167
-
168
- NEXO Brain automatically preserves session context when Claude Code compacts conversations. Using PreCompact and PostCompact hooks:
169
-
170
- - **PreCompact**: Saves a complete session checkpoint to SQLite (task, files, decisions, errors, reasoning thread, next step)
171
- - **PostCompact**: Re-injects a structured Core Memory Block into the conversation, so the session continues seamlessly
172
-
173
- This means long sessions (8+ hours) feel like one continuous conversation instead of restarting after each compaction.
174
-
175
- **How it works:**
176
- 1. Configure the hooks in your Claude Code `settings.json`
177
- 2. NEXO Brain's heartbeat automatically maintains the checkpoint
178
- 3. When compaction happens, the PreCompact hook reads the checkpoint and injects a recovery block
179
- 4. The session continues from exactly where it left off
180
-
181
- **Setup:**
182
- ```json
183
- {
184
- "hooks": {
185
- "PreCompact": [{
186
- "matcher": "*",
187
- "hooks": [{"type": "command", "command": "bash $NEXO_HOME/hooks/pre-compact.sh", "timeout": 10}]
188
- }],
189
- "PostCompact": [{
190
- "matcher": "*",
191
- "hooks": [{"type": "command", "command": "bash $NEXO_HOME/hooks/post-compact.sh", "timeout": 10}]
192
- }]
193
- }
194
- }
195
- ```
196
-
197
- 2 new MCP tools: `nexo_checkpoint_save` (manual or hook-triggered checkpoint), `nexo_checkpoint_read` (retrieves the latest checkpoint for context injection).
198
-
199
- ## Cognitive Features
200
-
201
- NEXO Brain provides **144+ MCP tools** across 20+ categories. These features implement cognitive science concepts that go beyond basic memory:
202
-
203
- ### Input Pipeline
204
-
205
- | Feature | What It Does |
206
- |---------|-------------|
207
- | **Prediction Error Gating** | Only novel information is stored. Redundant content that matches existing memories is rejected at write time, keeping your memory clean without manual curation. |
208
- | **Security Pipeline** | 4-layer defense against memory poisoning: injection detection, encoding analysis, behavioral anomaly scoring, and credential scanning. Every memory passes through all four layers before storage. |
209
- | **Quarantine Queue** | New facts enter quarantine status and must pass a promotion policy before becoming trusted knowledge. Prevents unverified information from influencing decisions. Automated nightly processing promotes, rejects, or expires items. |
210
- | **Secret Redaction** | Auto-detects and redacts API keys, tokens, passwords, and other sensitive data before storage. Secrets never reach the vector database. |
211
-
212
- ### Memory Management
213
-
214
- | Feature | What It Does |
215
- |---------|-------------|
216
- | **Pin / Snooze / Archive** | Granular lifecycle states for memories. Pin = never decays (critical knowledge). Snooze = temporarily hidden (revisit later). Archive = cold storage (searchable but inactive). |
217
- | **Intelligent Chunking** | Adaptive chunking that respects sentence and paragraph boundaries. Produces semantically coherent chunks instead of arbitrary token splits, reducing retrieval noise. |
218
- | **Adaptive Decay** | Decay rate adapts per memory based on access patterns: frequently-accessed memories decay slower, rarely-accessed ones fade faster. Prevents permanent clutter while keeping active knowledge sharp. |
219
- | **Auto-Migration** | Formal schema migration system (schema_migrations table) tracks all database changes. Safe, reversible schema evolution for production systems — upgrades never lose data. |
220
- | **Auto-Merge Duplicates** | Batch cosine deduplication during the 03:00 sleep cycle. Respects sibling discrimination — similar memories about different contexts are kept separate. |
221
- | **Memory Dreaming** | Discovers hidden connections between recent memories during the 03:00 sleep cycle. Surfaces non-obvious patterns like "these three bugs all relate to the same root cause." |
222
-
223
- ### Retrieval
224
-
225
- | Feature | What It Does |
226
- |---------|-------------|
227
- | **HyDE Query Expansion** | Generates hypothetical answer embeddings for richer semantic search. Instead of searching for "deploy error", it imagines what a helpful memory about deploy errors would look like, then searches for that. |
228
- | **Hybrid Search (FTS5+BM25+RRF)** | Combines dense vector search with BM25 keyword search via Reciprocal Rank Fusion. Outperforms pure semantic search on precise terminology and code identifiers. |
229
- | **Cross-Encoder Reranking** | After initial vector retrieval, a cross-encoder model rescores candidates for precision. The top-k results are reordered by true semantic relevance before being returned to the agent. |
230
- | **Multi-Query Decomposition** | Complex questions are automatically split into sub-queries. Each component is retrieved independently, then fused for a higher-quality answer — improves recall on multi-faceted prompts. |
231
- | **Temporal Indexing** | Memories are indexed by time in addition to semantics. Time-sensitive queries ("what did we decide last Tuesday?") use temporal proximity scoring alongside semantic similarity. |
232
- | **Spreading Activation** | Graph-based co-activation network. Memories retrieved together reinforce each other's connections, building an associative web that improves over time. |
233
- | **Recall Explanations** | Transparent score breakdown for every retrieval result. Shows exactly why a memory was returned: semantic similarity, recency, access frequency, and co-activation bonuses. |
234
-
235
- ### Proactive
236
-
237
- | Feature | What It Does |
238
- |---------|-------------|
239
- | **Prospective Memory** | Context-triggered reminders that fire when conversation topics match, not just by date. "Remind me about X when we discuss Y" works naturally. |
240
- | **Hook Auto-capture** | Extracts decisions, corrections, and factual statements from conversations automatically. You don't need to explicitly say "remember this" — the system detects what's worth storing. |
241
- | **Session Summaries** | Automatic end-of-session summarization that distills key decisions, errors, and follow-ups into a compact diary entry. The next session starts with full context — not a cold slate. |
242
- | **Smart Startup** | Pre-loads relevant cognitive memories at session boot by composing a query from pending followups, due reminders, and last session's topics. Every session starts with the right context — not a cold search. |
243
- | **Context Packets** | Bundles all area knowledge (learnings, recent changes, active followups, preferences, cognitive memories) into a single injectable packet for subagent delegation. Subagents never start blind again. |
244
- | **Auto-Prime by Topic** | Heartbeat detects project/area keywords in conversation and automatically surfaces the most relevant learnings. No explicit memory query needed — context arrives proactively. |
245
-
246
- ## Benchmark: LoCoMo (ACL 2024)
247
-
248
- NEXO Brain was evaluated on [LoCoMo](https://github.com/snap-research/locomo) (ACL 2024), a long-term conversation memory benchmark with 1,986 questions across 10 multi-session conversations.
249
-
250
- | System | F1 | Adversarial | Hardware |
251
- |---|---|---|---|
252
- | **NEXO Brain v0.5.0** | **0.588** | **93.3%** | **CPU only** |
253
- | GPT-4 (128K full context) | 0.379 | — | GPU cloud |
254
- | Gemini Pro 1.0 | 0.313 | — | GPU cloud |
255
- | LLaMA-3 70B | 0.295 | — | A100 GPU |
256
- | GPT-3.5 + Contriever RAG | 0.283 | — | GPU |
257
-
258
- **+55% vs GPT-4. Running entirely on CPU.**
259
-
260
- **Key findings:**
261
- - Outperforms GPT-4 (128K full context) by 55% on F1 score
262
- - 93.3% adversarial rejection rate — reliably says "I don't know" when information isn't available
263
- - 74.9% recall across 1,986 questions
264
- - Open-domain F1: 0.637 | Multi-hop F1: 0.333 | Temporal F1: 0.326
265
- - Runs on CPU with 768-dim embeddings (BAAI/bge-base-en-v1.5) — no GPU required
266
- - First MCP memory server benchmarked on a peer-reviewed dataset
267
-
268
- Full results in [`benchmarks/locomo/results/`](benchmarks/locomo/results/).
269
-
270
- ## Nervous System (v2.0.0)
271
-
272
- NEXO Brain doesn't just respond — it runs 14 autonomous processes in the background, like a biological nervous system. They handle maintenance, health monitoring, and self-improvement without any user interaction:
273
-
274
- | Script | Schedule | What It Does |
275
- |--------|----------|-------------|
276
- | **cognitive-decay** | 03:00 daily | Ebbinghaus decay + memory consolidation + duplicate merging + dreaming |
277
- | **sleep** | 04:00 daily | Synaptic pruning, expired data cleanup |
278
- | **deep-sleep** | 04:30 daily | 4-phase overnight pipeline: Collect→Extract→Synthesize→Apply. Analyzes all sessions, detects emotional patterns, abandoned projects, productivity issues, and auto-creates learnings |
279
- | **self-audit** | 07:00 daily | Health checks, guard stats, trust score review, metrics |
280
- | **postmortem** | 23:30 daily | Session consolidation, extract patterns from day's events |
281
- | **catchup** | On boot | Runs any missed scheduled processes (Mac was off/asleep) |
282
- | **tcc-approve** | On boot (macOS) | Auto-approve macOS permissions for Claude Code updates |
283
- | **prevent-sleep** | Optional opt-in daemon | Keeps machine awake for nocturnal processes when `power_policy=always_on` (caffeinate/systemd-inhibit) |
284
- | **evolution** | Weekly (Sun) | Self-improvement proposals — NEXO suggests and applies enhancements |
285
- | **followup-hygiene** | Weekly (Sun) | Normalizes statuses, flags stale followups, cleans orphans |
286
- | **learning-housekeep** | 03:15 daily | Dedup learnings, adjust weights by usage, process overdue reviews, reconcile decision outcomes |
287
- | **immune** | Every 30 min | Quarantine processing, memory promotion/rejection, synaptic pruning |
288
- | **synthesis** | 06:00 daily | Memory synthesis — discovers cross-memory patterns |
289
- | **watchdog** | Every 30 min | Monitors services, LaunchAgents, and infrastructure health |
290
- | **auto-close-sessions** | Every 5 min | Cleans stale sessions |
291
-
292
- Core processes are defined in `src/crons/manifest.json` and auto-synced to your system by `nexo_update`. On macOS they run via LaunchAgents; on Linux via systemd user timers. `tcc-approve`, `prevent-sleep`, and `backup` are platform/personal helpers — not in the manifest but listed above for completeness. `prevent-sleep` is opt-in via the persisted power policy (`always_on` / `disabled` / `unset`). Personal scripts (your own automations) are tracked separately in the Personal Scripts Registry, can declare their own recovery policy inline, and are never touched by the core sync. If your Mac was asleep during a scheduled process, the catch-up system can now recover both core crons and managed personal schedules according to their recovery contract.
293
-
294
- ## Deep Sleep v2 — Overnight Learning (v2.1.0)
295
-
296
- Deep Sleep is a 4-phase pipeline that runs at 4:30 AM and makes NEXO smarter while you sleep:
297
-
298
- ```
299
- Phase 1: COLLECT (Python)
300
- ├── Reads all session transcripts from the day
301
- ├── Splits each session into individual .txt files
302
- └── Gathers DB state (followups, learnings, trust)
303
-
304
- Phase 2: EXTRACT (Opus, one call per session)
305
- ├── 8 types of findings per session:
306
- │ ├── Uncaptured corrections (user corrected agent, no learning saved)
307
- │ ├── Self-corrected errors (knowledge gaps to fix)
308
- │ ├── Unformalised ideas (mentioned but never tracked)
309
- │ ├── Missed commitments (promised but no followup)
310
- │ ├── Protocol violations (guard_check, heartbeat, change_log)
311
- │ ├── Emotional signals (frustration, flow, satisfaction)
312
- │ ├── Abandoned projects (started but not finished)
313
- │ └── Productivity patterns (corrections, proactivity, tool efficiency)
314
- └── Outputs per-session JSON with findings + emotional timeline
315
-
316
- Phase 3: SYNTHESIZE (Opus, one call)
317
- ├── Cross-session patterns (same error in 5 sessions = systemic)
318
- ├── Daily mood arc with score (0.0 = terrible day, 1.0 = great day)
319
- ├── Recurring triggers (what causes frustration vs flow)
320
- ├── Productivity analysis (corrections, tool efficiency)
321
- ├── Abandoned project detection
322
- ├── Morning agenda (prioritized)
323
- └── Calibration recommendations
324
-
325
- Phase 4: APPLY (Python)
326
- ├── Auto-creates learnings from high-confidence findings
327
- ├── Creates followups for unfinished work
328
- ├── Updates mood_history in calibration.json (30-day rolling)
329
- ├── Generates session-tone.json (emotional guidance for next session)
330
- └── Writes morning-briefing.md
331
- ```
332
-
333
- ### Session Tone — Emotional Intelligence
334
-
335
- Deep Sleep generates a `session-tone.json` that tells NEXO how to behave next morning:
336
-
337
- - **Agent made many mistakes yesterday** → Acknowledge them, show what was learned, demonstrate improvement
338
- - **User had a bad day (mood < 40%)** → Supportive approach, lighter start, avoid known frustration triggers
339
- - **User had a great day (mood > 70%)** → Reinforce momentum, reference wins, push ambitious goals
340
- - **Agent was too reactive** → Be proactive today, don't wait for instructions
19
+ <p align="center">
20
+ <a href="https://www.npmjs.com/package/nexo-brain"><strong>Try it in 2 minutes</strong></a>
21
+ ·
22
+ <a href="https://www.youtube.com/watch?v=IBs7zh7ZMG0">Watch demo</a>
23
+ ·
24
+ <a href="https://nexo-brain.com/features/benchmark/">See benchmark</a>
25
+ ·
26
+ <a href="https://nexo-brain.com">Website</a>
27
+ </p>
341
28
 
342
- This is read by `nexo_smart_startup` and injected into every session's context. NEXO adapts its personality based on real behavioral data, not just configuration.
29
+ ## Why NEXO
343
30
 
344
- ## Cron Manifest & Scheduler (v2.4.0)
31
+ Without NEXO, your agent forgets everything between sessions, repeats mistakes, starts cold after compaction, and misses work when the machine sleeps.
345
32
 
346
- All core crons are defined in `src/crons/manifest.json`. When you run `nexo_update`, the sync script:
347
- - **Installs** new crons from the manifest
348
- - **Updates** changed schedules/intervals
349
- - **Removes** crons no longer in the manifest (only core ones)
350
- - **Never touches** personal crons you created yourself
33
+ With NEXO, you get:
351
34
 
352
- Every cron execution is tracked in the `cron_runs` table via a universal wrapper. Use `nexo_schedule_status` to see what ran overnight:
35
+ - Persistent memory with semantic retrieval, reinforcement, and natural forgetting
36
+ - A Claude Code-first runtime with `nexo chat`, `nexo update`, and `nexo doctor`
37
+ - Overnight learning via Deep Sleep and daily synthesis
38
+ - Recovery-aware background jobs with boot, wake, and catch-up handling
39
+ - Personal scripts as first-class managed entities
40
+ - Local-only storage: SQLite + ONNX Runtime, zero cloud dependency for the memory system itself
353
41
 
354
- ```
355
- ✅ deep-sleep: 1/1 OK, 4523s avg — 37 sessions, 259 findings
356
- ✅ immune: 48/48 OK, 2s avg
357
- ❌ evolution: 0/1 OK — CLI timeout
358
- ```
42
+ ## What You Get In 2 Minutes
359
43
 
360
- Add personal crons from conversation with `nexo_schedule_add` — generates LaunchAgent (macOS) or systemd timer (Linux) automatically.
44
+ After install, NEXO can:
361
45
 
362
- ## Skill Auto-Creation (v2.4.0)
46
+ - start Claude Code through `nexo chat`
47
+ - keep state across sessions and compactions
48
+ - run startup preflight before interactive use
49
+ - diagnose and repair runtime drift with `nexo doctor --fix`
50
+ - schedule and recover your own scripts in `NEXO_HOME/scripts/`
51
+ - run 13 core recovery-aware jobs plus optional helpers such as the dashboard and prevent-sleep
363
52
 
364
- Deep Sleep automatically extracts reusable procedures from successful multi-step tasks and stores them as skills with full procedural content (steps, gotchas, markdown).
53
+ ## Benchmark
365
54
 
366
- Pipeline: `trace draft → published → archived`. Trust rises with successful use, decays without it. No human approval gates.
55
+ NEXO was benchmarked on [LoCoMo](https://github.com/snap-research/locomo), the ACL 2024 long-conversation memory benchmark.
367
56
 
368
- 7 MCP tools: `nexo_skill_create`, `nexo_skill_match`, `nexo_skill_get`, `nexo_skill_result`, `nexo_skill_list`, `nexo_skill_merge`, `nexo_skill_stats`.
57
+ | System | F1 | Hardware |
58
+ | --- | --- | --- |
59
+ | **NEXO Brain benchmark build** | **0.588** | **CPU only** |
60
+ | GPT-4 (128K) | 0.379 | GPU cloud |
61
+ | Gemini Pro 1.0 | 0.313 | GPU cloud |
62
+ | LLaMA-3 70B | 0.295 | A100 GPU |
63
+ | GPT-3.5 + Contriever | 0.283 | GPU |
369
64
 
370
- ## Dashboard (v1.6.0)
65
+ That is **+55% vs GPT-4**, while running locally on CPU.
371
66
 
372
- A web interface at `localhost:6174` with 6 interactive pages for visual insight into your brain's state:
373
-
374
- | Page | What It Shows |
375
- |------|-------------|
376
- | **Overview** | System health at a glance — memory counts, trust score, active sessions, recent changes |
377
- | **Graph** | Interactive D3.js visualization of the knowledge graph (nodes, edges, clusters) |
378
- | **Memory** | Browse and search all memory stores (STM, LTM, sensory, archived) |
379
- | **Somatic** | Pain map per file/area — see which parts of your codebase cause the most errors |
380
- | **Adaptive** | Personality signals, learned weights, and current mode |
381
- | **Sessions** | Active and historical sessions with timeline and diary entries |
382
-
383
- Built with FastAPI backend and D3.js frontend. Dashboard files are installed to `NEXO_HOME/dashboard/` but must be started manually:
67
+ ## Install
384
68
 
385
69
  ```bash
386
- python3 ~/.nexo/dashboard/app.py
70
+ npx nexo-brain
387
71
  ```
388
72
 
389
- This opens `localhost:6174` in your browser. Add `--port 8080` to change the port or `--no-browser` to skip auto-opening.
73
+ NEXO will:
390
74
 
391
- ## Full Orchestration System
75
+ 1. create `NEXO_HOME`
76
+ 2. install the local runtime
77
+ 3. configure the MCP server for Claude Code
78
+ 4. install the core background jobs
79
+ 5. ask the new runtime questions it needs for behavior and power policy
392
80
 
393
- Memory alone doesn't make a co-operator. What makes the difference is the **behavioral loop** — the automated discipline that ensures every session starts informed, runs with guardrails, and ends with self-reflection. The hooks and lifecycle below are built into the core product. The optional Day Orchestrator (autonomous headless cycles) was removed from core in v2.6.0 — power users can set it up as a personal script.
81
+ After install:
394
82
 
395
- ### Automated Hooks
396
-
397
- 7 hooks fire automatically at key moments in every Claude Code session:
398
-
399
- | Hook | When | What It Does |
400
- |------|------|-------------|
401
- | **SessionStart (timestamp)** | Session opens | Writes session timestamp for staleness detection |
402
- | **SessionStart (briefing)** | Session opens | Generates briefing from SQLite: overdue reminders, today's tasks, pending followups, active sessions. Cleans up post-mortem flags. |
403
- | **Stop** | Session ends | Mandatory post-mortem: self-critique (5 questions), session buffer entry, followup creation, proactive seeds for next session |
404
- | **PostToolUse (capture)** | After each tool call | Captures meaningful mutations to the Sensory Register + auto-diary every 10 tool calls |
405
- | **PostToolUse (inbox)** | After each tool call | Inter-terminal inbox delivery between parallel sessions |
406
- | **PreCompact** | Before context compression | Saves full session checkpoint to SQLite — task, files, decisions, errors, reasoning thread + emergency diary |
407
- | **PostCompact** | After context compression | Re-injects Core Memory Block so the session continues seamlessly from where it left off |
408
-
409
- ### The Session Lifecycle
410
-
411
- ```
412
- Session starts
413
-
414
- SessionStart hook generates briefing
415
-
416
- Operator reads diary, reminders, followups
417
-
418
- Heartbeat on every interaction (sentiment, context shifts)
419
-
420
- Guard check before every code edit
421
-
422
- PreCompact hook saves full checkpoint if conversation is compressed
423
-
424
- PostCompact hook re-injects Core Memory Block → session continues seamlessly
425
-
426
- Stop hook triggers mandatory post-mortem:
427
- - Self-critique: 5 questions about what could be better
428
- - Session buffer: structured entry for the reflection engine
429
- - Followups: anything promised gets scheduled
430
- - Proactive seeds: what can the next session do without being asked?
431
-
432
- Reflection engine processes buffer (after 3+ sessions)
433
-
434
- Nocturnal processes: decay, consolidation, self-audit, dreaming
83
+ ```bash
84
+ nexo chat
435
85
  ```
436
86
 
437
- ### Reflection Engine
87
+ Useful commands:
438
88
 
439
- After 3+ sessions accumulate, the stop hook triggers `nexo-reflection.py`:
440
- - Extracts recurring tasks, error patterns, mood trends
441
- - Updates `user_model.json` with observed behavior
442
- - No LLM required — runs as pure Python
443
-
444
- ### Auto-Migration
445
-
446
- Existing users upgrading from any previous version:
447
89
  ```bash
448
- npx nexo-brain # detects current version, migrates automatically
90
+ nexo -v
91
+ nexo update
92
+ nexo doctor --tier runtime --json
93
+ nexo doctor --tier runtime --fix
94
+ nexo scripts list
95
+ nexo scripts reconcile
449
96
  ```
450
- - Updates hooks, core files, plugins, scripts, and LaunchAgent templates
451
- - Runs database schema migrations automatically
452
- - **Never touches your data** (memories, learnings, preferences)
453
- - Saves updated CLAUDE.md as reference (doesn't overwrite customizations)
454
97
 
455
- ## Knowledge Graph (v0.8)
98
+ ## What Makes It Different
456
99
 
457
- A bi-temporal entity-relationship graph with 988 nodes and 896 edges. Entities and relationships carry both valid-time (when the fact was true) and system-time (when it was recorded), enabling temporal queries like "what did we know about X last Tuesday?". BFS traversal discovers multi-hop connections between concepts. Event-sourced edges with smart dedup (ADD/UPDATE/NOOP) prevent redundant writes while preserving full history.
100
+ NEXO is not just a vector store and not just a memory plugin.
458
101
 
459
- 4 MCP tools: `nexo_kg_query` (SPARQL-like queries), `nexo_kg_path` (shortest path between entities), `nexo_kg_neighbors` (direct connections), `nexo_kg_stats` (graph metrics).
102
+ It combines:
460
103
 
461
- ### Cross-Platform Support
462
- Full Linux support and Windows via WSL. The installer detects the platform and configures the appropriate process manager (LaunchAgents on macOS, catch-up on startup for Linux). PEP 668 compliance (venv on Ubuntu 24.04+). Session keepalive prevents phantom sessions during long tasks. Opportunistic maintenance runs cognitive processes when resources are available.
104
+ - persistent memory
105
+ - metacognitive guardrails
106
+ - startup/update/runtime operations
107
+ - autonomous maintenance jobs
108
+ - wake recovery and missed-run catch-up
109
+ - personal automation
463
110
 
464
- > **Windows users:** NEXO Brain requires [WSL (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/install). Install WSL first, then run `npx nexo-brain` inside the Ubuntu/WSL terminal.
111
+ That combination is what turns Claude Code from a stateless assistant into a durable operator.
465
112
 
466
- ### Storage Router
467
- A new abstraction layer routes storage operations through a unified interface, making the system multi-tenant ready. Each operator's data is isolated while sharing the same cognitive engine.
113
+ ## Core Capabilities
468
114
 
469
- ## Learned Weights & Somatic Markers (v0.7.0)
115
+ ### 1. Persistent Cognitive Memory
470
116
 
471
- ### Adaptive Learned Weights
472
- Signal weights learn from real user feedback via Ridge regression. A 2-week shadow mode observes before activating. Weight momentum (85/15 blend) prevents personality whiplash. Automatic rollback if correction rate doubles.
117
+ - Three-store memory model inspired by Atkinson-Shiffrin
118
+ - Semantic retrieval by meaning, not just keywords
119
+ - Reinforcement and forgetting curves instead of infinite clutter
120
+ - Learnings, followups, reminders, entities, and episodic history
473
121
 
474
- ### Somatic Markers (Pain Memory)
475
- Files and areas that cause repeated errors accumulate a risk score (0.0–1.0). The guard system warns on HIGH RISK (>0.5) and CRITICAL RISK (>0.8), lowering thresholds for more paranoid checking. Clean guard checks reduce risk multiplicatively (×0.7). Nightly decay (×0.95) ensures old pain fades.
122
+ ### 2. Guardrails Before Action
476
123
 
477
- ### Adaptive Personality v2
478
- 6 weighted signals: vibe, corrections, brevity, topic, tool errors, git diff. Emergency keywords bypass hysteresis. Severity-weighted decay. Manual override via `nexo_adaptive_override`.
124
+ - Guard checks before edits
125
+ - Trust scoring and behavioral calibration
126
+ - Cognitive dissonance when new instructions conflict with prior knowledge
127
+ - Startup context continuity across compaction
479
128
 
480
- ## Quick Start
129
+ ### 3. Runtime Operations
481
130
 
482
- ### Claude Code (Primary)
131
+ - `nexo chat` to launch Claude Code with NEXO as operator
132
+ - `nexo update` to sync and migrate the runtime
133
+ - `nexo doctor` for boot/runtime/deep diagnostics
134
+ - startup preflight with safe local migrations and deferred remote update policy
483
135
 
484
- ```bash
485
- npx nexo-brain
486
- ```
136
+ ### 4. Recovery-Aware Background Jobs
487
137
 
488
- The installer handles everything:
138
+ Core jobs are declared in `src/crons/manifest.json` and synced automatically.
489
139
 
490
- ```
491
- How should I call myself? (default: NEXO) > Atlas
492
-
493
- Can I explore your workspace to learn about your projects? (y/n) > y
494
-
495
- Keep Mac awake so my cognitive processes run on schedule? (y/n) > y
496
-
497
- Installing cognitive engine dependencies...
498
- Setting up NEXO home...
499
- Scanning workspace...
500
- - 3 git repositories
501
- - Node.js project detected
502
- Configuring MCP server...
503
- Setting up nervous system...
504
- 14 autonomous processes configured.
505
- Dashboard configured at localhost:6174.
506
- Caffeinate enabled.
507
- Generating operator instructions...
508
-
509
- +----------------------------------------------------------+
510
- | Atlas is ready. Type 'atlas' to start. |
511
- +----------------------------------------------------------+
512
- ```
140
+ They cover:
513
141
 
514
- ### Starting a Session
142
+ - decay and consolidation
143
+ - Deep Sleep analysis
144
+ - immune and watchdog checks
145
+ - synthesis, self-audit, postmortem
146
+ - catch-up and stale-session cleanup
515
147
 
516
- The installer creates a shell alias with your chosen name. Just type it:
148
+ These jobs now declare explicit recovery contracts such as `catchup`, `restart`, boot/wake behavior, idempotency, and catch-up windows.
517
149
 
518
- ```bash
519
- atlas
520
- ```
150
+ ### 5. Personal Scripts
521
151
 
522
- Under the hood, the alias runs:
523
- ```bash
524
- claude --dangerously-skip-permissions "."
525
- ```
526
- `--dangerously-skip-permissions` launches Claude Code with tool-use permissions pre-approved so the operator can act autonomously. The `"."` triggers the operator to start immediately. Operator behavior (startup, context, greeting) is defined in `~/.claude/CLAUDE.md`.
527
-
528
- That's it. No need to run `claude` manually. Your operator will greet you immediately — adapted to the time of day, resuming from where you left off if there's a previous session. No cold starts, no waiting for your input.
529
-
530
- ### What Gets Installed
531
-
532
- | Component | What | Where |
533
- |-----------|------|-------|
534
- | Cognitive engine | Python: fastembed, numpy, vector search | pip packages |
535
- | MCP server | 144+ tools for memory, cognition, learning, guard | NEXO_HOME/ |
536
- | Plugins | Guard, episodic memory, cognitive memory, entities, preferences, update, etc. | Code: src/plugins/, Personal: NEXO_HOME/plugins/ |
537
- | Hooks (7) | SessionStart, Stop, PostToolUse, PreCompact, PostCompact | NEXO_HOME/hooks/ |
538
- | Nervous system | 14 autonomous processes (decay, sleep, audit, evolution, watchdog, dashboard, etc.) | NEXO_HOME/scripts/ |
539
- | Dashboard | Web UI at localhost:6174 (23 modules, dark theme) — opt-in, always-on | NEXO_HOME/dashboard/ |
540
- | Runtime CLI | `nexo` command: chat, scripts, doctor, skills, update | NEXO_HOME/bin/ |
541
- | Doctor | Unified diagnostics: boot/runtime/deep tiers, `--fix` mode | src/doctor/ |
542
- | Skills v2 | Executable skills with guide/execute/hybrid modes, approval levels | NEXO_HOME/skills/ |
543
- | Personal Scripts Registry | User-defined scripts tracked in SQLite with scheduling, reconciliation, and 9 MCP tools | NEXO_HOME/scripts/ |
544
- | CLAUDE.md | Complete operator instructions (Codex, hooks, guard, trust, memory) | ~/.claude/CLAUDE.md |
545
- | Schedule config | schedule.json with customizable process times and timezone | NEXO_HOME/config/ |
546
- | Auto-update | Non-blocking startup check (5s max), opt-out via schedule.json | Built into server startup |
547
- | CLAUDE.md tracker | Version-tracked core sections with safe updates preserving customizations | Built into auto-update |
548
- | Auto-diary | 3-layer system: PostToolUse every 10 calls, PreCompact emergency, heartbeat DIARY_OVERDUE | Built into hooks |
549
- | Claude Code config | MCP server + 7 hooks + core processes registered | ~/.claude/settings.json |
550
-
551
- ### Runtime CLI
552
-
553
- After installation or auto-update, NEXO adds `NEXO_HOME/bin` to your shell `PATH`. Open a new terminal and the `nexo` command provides operational tools:
152
+ Scripts in `NEXO_HOME/scripts/` are first-class managed objects.
554
153
 
555
- ```bash
556
- # Claude Code
557
- nexo chat # Launch Claude Code in the current directory
558
- nexo chat ~/claude # Launch Claude Code in a specific directory
559
-
560
- # Personal Scripts
561
- nexo scripts list # List your personal scripts
562
- nexo scripts run my-script # Run a script with injected NEXO env
563
- nexo scripts doctor # Validate all personal scripts
564
- nexo scripts call nexo_learning_search --input '{"query":"cron"}' # Call any MCP tool
565
-
566
- # Skills v2
567
- nexo skills sync # Sync filesystem skill definitions into SQLite
568
- nexo skills list # List published/stable skills
569
- nexo skills get SK-... # Inspect a skill definition
570
- nexo skills apply SK-... --dry-run --json # Resolve guide/execute/hybrid without running it
571
- nexo skills approve SK-... --execution-level local --approved-by Francisco # Optional metadata override
572
- nexo skills evolution # Show text→script and improvement candidates
573
-
574
- # Unified Doctor
575
- nexo doctor # Quick boot diagnostics
576
- nexo doctor --tier all # Full system check (boot + runtime + deep)
577
- nexo doctor --tier runtime --json # Machine-readable health report
578
- nexo doctor --fix # Apply deterministic repairs
579
- ```
154
+ They support:
580
155
 
581
- Personal scripts live in `NEXO_HOME/scripts/` with inline metadata and are tracked in a first-class registry (SQLite). 9 MCP tools manage the full lifecycle: `nexo_personal_scripts_list`, `nexo_personal_script_create`, `nexo_personal_script_remove`, `nexo_personal_scripts_reconcile`, `nexo_personal_scripts_sync`, `nexo_personal_scripts_classify`, `nexo_personal_script_schedules`, `nexo_personal_script_unschedule`, `nexo_personal_scripts_ensure_schedules`. See `docs/writing-scripts.md` for details.
156
+ - inline metadata
157
+ - scheduling
158
+ - reconciliation
159
+ - doctor validation
160
+ - recovery policies such as `run_once_on_wake` and `catchup`
582
161
 
583
- Skills v2 combine procedural guides with optional executable scripts. Personal skills live in `NEXO_HOME/skills/`, packaged core skills live in `NEXO_CODE/skills/` during development and `NEXO_HOME/skills-core/` in installed environments, and staged runtime copies live in `NEXO_HOME/skills-runtime/`. Execution is fully autonomous: Deep Sleep can evolve mature guide skills into executable drafts automatically, and runtime execution no longer waits for manual approval. See `docs/skills-v2.md` for the full model.
162
+ This means your own automations can survive sleep, missed runs, and runtime updates through the same operational flow as the core runtime.
584
163
 
585
- The Doctor system reads existing health artifacts (immune, watchdog, self-audit) without triggering repairs in default mode.
164
+ ### 6. Power And Sleep
586
165
 
587
- ### Requirements
166
+ NEXO supports an optional power helper when `power_policy=always_on`.
588
167
 
589
- - **macOS or Linux** (Windows via [WSL](https://learn.microsoft.com/en-us/windows/wsl/install))
590
- - **Node.js 18+** (for the installer)
591
- - **Claude Opus (latest version) strongly recommended.** NEXO Brain provides 144+ MCP tools across 20+ categories. This cognitive load requires a top-tier model with large context window. Smaller models (Haiku, Sonnet) may struggle with tool selection and produce inconsistent results. Opus handles all 144+ tools without hesitation.
592
- - Python 3, Homebrew, and Claude Code are installed automatically if missing.
168
+ - On macOS, NEXO uses native `caffeinate`
169
+ - On Linux, it uses `systemd-inhibit` or `caffeine` when available
170
+ - This is **best effort background availability**, not a blanket promise of closed-lid 24/7 operation on every laptop
171
+ - Wake recovery and catch-up remain part of the contract
593
172
 
594
173
  ## Architecture
595
174
 
596
- ### Unified Code/Data Separation (v2.0.0)
597
-
598
- NEXO Brain separates **code** (immutable, in the repo or npm package) from **data** (personal, in `NEXO_HOME`):
599
-
600
- | Path | Contents |
601
- |------|----------|
602
- | `src/` (or npm package) | Server, plugins, hooks, scripts — never modified at runtime |
603
- | `NEXO_HOME/` (default `~/.nexo/`) | Database, config, personal plugins, schedule, backups |
604
- | `NEXO_HOME/config/schedule.json` | Customizable process schedules, timezone, auto_update flag |
605
- | `NEXO_HOME/plugins/` | Personal plugins that override or extend repo plugins |
606
- | `NEXO_HOME/data/` | SQLite databases (nexo.db, cognitive.db), migration state |
607
-
608
- The plugin loader scans `src/plugins/` first (base), then `NEXO_HOME/plugins/` (personal override by filename). This dual-directory approach lets you extend NEXO without forking the repo.
609
-
610
- ### 144+ MCP Tools across 20+ Categories
611
-
612
- | Category | Count | Tools | Purpose |
613
- |----------|-------|-------|---------|
614
- | Cognitive | 8 | retrieve, stats, inspect, metrics, dissonance, resolve, sentiment, trust | The brain — memory, RAG, trust, mood |
615
- | Cognitive Input | 5 | prediction_gate, security_scan, quarantine, promote, redact | Input pipeline — gating, security, quarantine |
616
- | Cognitive Advanced | 8 | hyde_search, spread_activate, explain_recall, dream, prospect, hook_capture, pin, archive | Advanced retrieval, proactive, lifecycle |
617
- | Guard | 3 | check, stats, log_repetition | Metacognitive error prevention |
618
- | Episodic | 10 | change_log/search/commit, decision_log/outcome/search, review_queue, diary_write/read, recall | What happened and why |
619
- | Sessions | 4 | startup, heartbeat, stop, status | Session lifecycle + context shift detection + inter-terminal auto-inbox |
620
- | Coordination | 7 | track, untrack, files, send, ask, answer, check_answer | Multi-session file coordination + messaging |
621
- | Reminders | 5 | list, create, update, complete, delete | User's tasks and deadlines |
622
- | Followups | 4 | create, update, complete, delete | System's autonomous verification tasks |
623
- | Learnings | 5 | add, search, update, delete, list | Error patterns and prevention rules |
624
- | Credentials | 5 | create, get, update, delete, list | Local credential storage (plaintext SQLite — protect with filesystem permissions) |
625
- | Task History | 3 | log, list, frequency | Execution tracking and overdue alerts |
626
- | Menu | 1 | menu | Operations center with box-drawing UI |
627
- | Entities | 5 | search, create, update, delete, list | People, services, URLs |
628
- | Preferences | 4 | get, set, list, delete | Observed user preferences |
629
- | Agents | 5 | get, create, update, delete, list | Agent delegation registry |
630
- | Backup | 3 | now, list, restore | SQLite data safety |
631
- | Evolution | 5 | propose, approve, reject, status, history | Self-improvement proposals |
632
- | Adaptive & Somatic | 4 | adaptive_weights, adaptive_override, somatic_check, somatic_stats | Learned signal weights + pain memory per file |
633
- | Knowledge Graph | 4 | kg_query, kg_path, kg_neighbors, kg_stats | Bi-temporal entity-relationship graph |
634
- | Context Continuity | 2 | checkpoint_save, checkpoint_read | Auto-compaction session preservation |
635
- | Personal Scripts | 9 | personal_scripts_list, personal_script_create, personal_script_remove, personal_scripts_reconcile, personal_scripts_sync, personal_scripts_classify, personal_script_schedules, personal_script_unschedule, personal_scripts_ensure_schedules | First-class script registry with lifecycle, scheduling, and reconciliation |
636
- | Update | 1 | update | Pull latest code, backup, migrate, verify (with rollback) |
637
-
638
- ### Plugin System
639
-
640
- NEXO Brain supports hot-loadable plugins with a dual-directory loader. Base plugins live in `src/plugins/` (repo). Personal plugins go in `NEXO_HOME/plugins/` and can override base plugins by filename. Drop a `.py` file in `NEXO_HOME/plugins/`:
641
-
642
- ```python
643
- # my_plugin.py
644
- def handle_my_tool(query: str) -> str:
645
- """My custom tool description."""
646
- return f"Result for {query}"
647
-
648
- TOOLS = [
649
- (handle_my_tool, "nexo_my_tool", "Short description"),
650
- ]
651
- ```
652
-
653
- Reload without restarting: `nexo_plugin_load("my_plugin.py")`
654
-
655
- ### Data Privacy
656
-
657
- - **Everything stays local.** All data in `~/.nexo/`, never uploaded anywhere.
658
- - **No telemetry.** No analytics. No phone-home.
659
- - **No cloud dependencies.** Vector search runs on CPU (fastembed), not an API.
660
- - **Auto-update is resilient.** NEXO checks for updates on startup. If an update fails, it continues with the current version and notifies you. Local migrations (database schema, configuration) always run. Network updates (git pull) can be disabled by setting `auto_update: false` in `NEXO_HOME/config/schedule.json`.
661
- - **Secret redaction.** API keys and tokens are stripped before they ever reach memory storage.
662
-
663
- ## The Psychology Behind NEXO Brain
664
-
665
- NEXO Brain isn't just engineering — it's applied cognitive psychology:
666
-
667
- | Psychological Concept | How NEXO Brain Implements It |
668
- |----------------------|----------------------|
669
- | Atkinson-Shiffrin (1968) | Three memory stores: sensory register --> STM --> LTM |
670
- | Ebbinghaus Forgetting Curve (1885) | Exponential decay: `strength = strength * e^(-lambda * time)` |
671
- | Rehearsal Effect | Accessing a memory resets its strength to 1.0 |
672
- | Memory Consolidation | Nightly process promotes frequently-used STM to LTM |
673
- | Prediction Error | Only surprising (novel) information gets stored — redundant input is gated |
674
- | Spreading Activation (Collins & Loftus, 1975) | Retrieving a memory co-activates related memories through an associative graph |
675
- | HyDE (Gao et al., 2022) | Hypothetical document embeddings improve semantic recall |
676
- | Prospective Memory (Einstein & McDaniel, 1990) | Context-triggered intentions fire when cue conditions match |
677
- | Metacognition | Guard system checks past errors before acting |
678
- | Cognitive Dissonance (Festinger, 1957) | Detects and verbalizes conflicts between old and new knowledge |
679
- | Theory of Mind | Models user behavior, preferences, and mood |
680
- | Synaptic Pruning | Automated cleanup of weak, unused memories |
681
- | Associative Memory | Semantic search finds related concepts, not just matching words |
682
- | Memory Reconsolidation | Dreaming process discovers hidden connections during sleep |
683
-
684
- ## Integrations
685
-
686
- ### Claude Code (Primary)
687
-
688
- NEXO Brain is designed as an MCP server. Claude Code is the primary supported client:
689
-
690
- ```bash
691
- npx nexo-brain
692
- ```
175
+ NEXO is built around a local runtime:
693
176
 
694
- All 144+ tools are available immediately after installation. The installer configures Claude Code's `~/.claude/settings.json` automatically.
177
+ - SQLite for state
178
+ - ONNX Runtime for embeddings
179
+ - FastMCP server for tool exposure
180
+ - LaunchAgents on macOS and systemd user units on Linux
695
181
 
696
- ### OpenClaw
182
+ The public product surface today is centered on:
697
183
 
698
- NEXO Brain also works as a cognitive memory backend for [OpenClaw](https://github.com/openclaw/openclaw):
184
+ - **150+ MCP tools**
185
+ - **23-module optional dashboard**
186
+ - **13 core recovery-aware jobs**
187
+ - **local-first operation**
699
188
 
700
- #### MCP Bridge (Zero Code)
189
+ ## Best Fit
701
190
 
702
- Add NEXO Brain to your OpenClaw config at `~/.openclaw/openclaw.json`:
191
+ NEXO is a strong fit if you want:
703
192
 
704
- ```json
705
- {
706
- "mcp": {
707
- "servers": {
708
- "nexo-brain": {
709
- "command": "python3",
710
- "args": ["~/.nexo/server.py"],
711
- "env": {
712
- "NEXO_HOME": "~/.nexo"
713
- }
714
- }
715
- }
716
- }
717
- }
718
- ```
193
+ - Claude Code to remember decisions, preferences, and lessons
194
+ - local-first memory with zero SaaS dependency for storage/retrieval
195
+ - automated overnight learning and operator-style maintenance
196
+ - first-class personal scripts instead of brittle ad-hoc cron hacks
719
197
 
720
- Or via CLI:
198
+ It is probably not the right tool if you only want a tiny single-purpose memory store or a hosted cloud platform.
721
199
 
722
- ```bash
723
- openclaw mcp set nexo-brain '{"command":"python3","args":["~/.nexo/server.py"],"env":{"NEXO_HOME":"~/.nexo"}}'
724
- openclaw gateway restart
725
- ```
200
+ ## Docs
726
201
 
727
- #### ClawHub Skill
202
+ - Website: <https://nexo-brain.com>
203
+ - Features: <https://nexo-brain.com/features/>
204
+ - Benchmark: <https://nexo-brain.com/features/benchmark/>
205
+ - Changelog: <https://nexo-brain.com/changelog/>
206
+ - Wiki: <https://github.com/wazionapps/nexo/wiki>
207
+ - npm: <https://www.npmjs.com/package/nexo-brain>
728
208
 
729
- ```bash
730
- npx clawhub@latest install nexo-brain
731
- ```
209
+ ## Contributing
732
210
 
733
- #### Native Memory Plugin
211
+ Issues and PRs are welcome. If you are testing runtime behavior, please include:
734
212
 
735
- ```bash
736
- npm install @wazionapps/openclaw-memory-nexo-brain
737
- ```
738
-
739
- ```json
740
- {
741
- "plugins": {
742
- "slots": {
743
- "memory": "memory-nexo-brain"
744
- }
745
- }
746
- }
747
- ```
748
-
749
- This replaces OpenClaw's default memory system with NEXO Brain's full cognitive architecture.
750
-
751
- ### Any MCP Client
752
-
753
- NEXO Brain works with any application that supports the MCP protocol. Configure it as an MCP server pointing to `server.py` inside `NEXO_HOME` (default `~/.nexo/server.py`), with the `NEXO_HOME` env var set to the same directory.
754
-
755
- ## Listed On
756
-
757
- | Directory | Type | Link |
758
- |-----------|------|------|
759
- | npm | Package | [nexo-brain](https://www.npmjs.com/package/nexo-brain) |
760
- | Glama | MCP Directory | [glama.ai](https://glama.ai/mcp/servers/@wazionapps/nexo) |
761
- | mcp.so | MCP Directory | [mcp.so](https://mcp.so/server/nexo/wazionapps) |
762
- | mcpservers.org | MCP Directory | [mcpservers.org](https://mcpservers.org) |
763
- | OpenClaw | Native Plugin | [openclaw.com](https://openclaw.ai) |
764
- | dev.to | Technical Article | [How I Applied Cognitive Psychology to AI Agents](https://dev.to/wazionapps/how-i-applied-cognitive-psychology-to-give-ai-agents-real-memory-2oce) |
765
- | nexo-brain.com | Official Website | [nexo-brain.com](https://nexo-brain.com) |
766
-
767
- ## Inspired By
768
-
769
- NEXO Brain builds on ideas from several open-source projects. We're grateful for the research and implementations that inspired specific features:
770
-
771
- | Project | Inspired Features |
772
- |---------|------------------|
773
- | Vestige | HyDE query expansion, spreading activation, prediction error gating, memory dreaming, prospective memory |
774
- | ShieldCortex | Security pipeline (4-layer memory poisoning defense) |
775
- | Bicameral | Quarantine queue (trust promotion policy for new facts) |
776
- | claude-mem | Hook auto-capture (extracting decisions and facts from conversations) |
777
- | ClawMem | Co-activation reinforcement (memories retrieved together strengthen connections) |
778
-
779
- ## Support the Project
780
-
781
- If NEXO Brain is useful to you, consider:
782
-
783
- - **Star this repo** — it helps others discover the project and motivates continued development
784
- - **[Sponsor on GitHub](https://github.com/sponsors/wazionapps)** — support ongoing development directly
785
- - **Share your experience** — tell others how you're using cognitive memory in your AI workflows
786
- - **Contribute** — see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Issues and PRs welcome
787
-
788
- [![Star History Chart](https://api.star-history.com/svg?repos=wazionapps/nexo&type=Date)](https://star-history.com/#wazionapps/nexo&Date)
789
-
790
- ## Known Issues
791
-
792
- | Priority | Issue | Status |
793
- |----------|-------|--------|
794
- | P1 | Credentials stored in plaintext SQLite — protect with filesystem permissions | Mitigated: secret redaction in tool logs (v2.4.0) |
795
- | P2 | Dashboard has no authentication (localhost only) | By design — bind to localhost, no remote access |
796
-
797
- ## Changelog
798
-
799
- ### v2.6.0 — Personal Scripts Registry, Plugin Marketplace, Orchestrator Decoupled (2026-04-03)
800
- - **Personal Scripts Registry**: First-class script tracking in SQLite with 9 MCP tools for full lifecycle management — create, list, remove, schedule, unschedule, reconcile, sync, classify.
801
- - **Orchestrator removed from core**: Day Orchestrator decoupled from the product. Power users keep it as a personal script. Reduces complexity for standard installs.
802
- - **Claude Code plugin structure**: `plugin.json` + entry point for Anthropic marketplace submission.
803
- - **`nexo chat`**: Official CLI command to launch Claude Code with NEXO as operator.
804
- - **Managed Evolution hardening**: Can now modify core behavior modules with rollback followups. Fixed false-positive watchdog tamper detection.
805
- - **Cron reliability**: Hardened recovery, TCC diagnostics, keepalive sync, disabled optional cron respect.
806
- - **Duplicate learning prevention**: Exact-title guard before insert.
807
-
808
- ### v2.5.0 — Runtime CLI, Doctor, Skills v2, Day Orchestrator (2026-04-03)
809
- - **Runtime CLI** (`nexo`): New operational CLI separate from installer. `nexo scripts list/run/doctor/call` for personal scripts, `nexo doctor` for diagnostics, `nexo skills apply` for executable skills, `nexo update` for one-step sync.
810
- - **Unified Doctor**: Modular diagnostic system with boot/runtime/deep tiers. Report-only by default, deterministic `--fix` mode. MCP tool `nexo_doctor`. LaunchAgent schedule drift detection and reconciliation.
811
- - **Skills v2**: Executable skills with guide/execute/hybrid modes. Security levels (read-only/local/remote) with explicit approval. Core vs personal vs community directories. Deep Sleep auto-evolution integration.
812
- - **Day Orchestrator**: Autonomous NEXO cycles every 15 min (8:00-23:00). *(Removed from core in v2.6.0 — available as personal script.)*
813
- - **Dashboard always-on**: Web UI at localhost:6174 as persistent LaunchAgent. 23 modules, Jinja2 templating, dark theme. Opt-in.
814
- - **Personal Scripts Framework**: Auto-discovery in NEXO_HOME/scripts/, inline metadata, runtime detection, forbidden-pattern validation. *(Promoted to first-class registry in v2.6.0.)*
815
- - Configurable operator name (UserContext singleton), watchdog normalized to 30 min, LaunchAgent drift fix.
816
-
817
- ### v2.4.0 — Skills, Cron Scheduler, Security, Full Audit (2026-04-03)
818
- - **Skill Auto-Creation**: Deep Sleep extracts reusable procedures from sessions. Content stored as markdown with steps and gotchas. Trust pipeline with autonomous quality control.
819
- - **Cron Scheduler**: execution tracking (`cron_runs` table), `nexo_schedule_status` and `nexo_schedule_add` MCP tools, universal cron wrapper for all processes.
820
- - **Deep Sleep v2.4**: watermark-based collection (late-night sessions included), per-session checkpointing (crash-safe), retry x3, JSON parsing fix, auto-calibration of personality settings.
821
- - **Security**: credential redaction in tool logs, transcript sanitization, command injection fix in dashboard, path traversal protection in plugin loader.
822
- - **Diary filter**: startup only shows human sessions, auto-closed cron sessions filtered out. Email sessions preserved as real interactions.
823
- - **Preflight CI**: 66 automated checks (py_compile, bash -n, manifest consistency, npm artifact, forbidden markers).
824
- - **Python 3.9 compat**: `from __future__ import annotations` across 18 files.
825
- - **Linux**: full systemd timer support, .bashrc alias for interactive shells.
826
- - Passed 5-phase automated audit: Product, Failure, Security, Packaging, UX.
827
-
828
- ### v2.2.0 — Trust Score v2 (2026-04-01)
829
- - **Trust Score**: fair daily calibration from Deep Sleep analysis. Score 0-100 based on corrections, autonomy, proactivity.
830
- - **Cognitive Quarantine**: new memories go through quarantine before promotion to LTM.
831
-
832
- ### v2.0.0 — Unified Architecture (2026-03-31)
833
- - **Code/data separation**: Code in repo (`src/`), personal data in `NEXO_HOME` (default `~/.nexo/`). `NEXO_HOME` env var required.
834
- - **Plugin loader dual-directory**: Scans `src/plugins/` (base) then `NEXO_HOME/plugins/` (personal override by filename).
835
- - **Auto-update on startup**: Non-blocking (5s max), resilient, opt-out via `schedule.json`. Separate from manual `nexo_update` tool.
836
- - **Auto-diary**: 3-layer system — PostToolUse every 10 calls, PreCompact emergency save, heartbeat DIARY_OVERDUE signal.
837
- - **CLAUDE.md version tracker**: Section markers enable safe core updates without losing user customizations.
838
- - **schedule.json**: Customizable process schedules with timezone support and `auto_update` flag.
839
- - **14 autonomous processes**: Added auto-close-sessions, synthesis, backup, tcc-approve, prevent-sleep (cross-platform).
840
- - **7 hooks**: SessionStart (timestamp + briefing), Stop, PostToolUse (capture + inbox), PreCompact, PostCompact.
841
- - **144+ MCP tools**: Added `nexo_update` tool for manual updates with rollback.
842
- - **Lambda fix**: Decay values were 24x too aggressive (STM: 7h to 7d, LTM: 2.4d to 60d).
843
- - **Guard scoping**: Was returning 35+ irrelevant blocking rules; now scoped to area and gated to high/critical.
844
- - **12 rounds of external audit**: ~60 findings resolved.
845
-
846
- ### v1.7.0 — Full Internationalization + Linux Support (2026-03-31)
847
- - **Full i18n**: All UI strings, error messages, DB status values in English. NLP detection patterns retain bilingual keywords (Spanish + English) for multilingual user support.
848
- - **Linux support**: systemd user timers (preferred) or crontab fallback for all automated cognitive processes.
849
- - **Auto-resolve followups**: Change log entries automatically cross-reference and complete matching open followups.
850
- - **Free-form learning categories**: No more hardcoded category validation — use any category name.
851
- - **CLAUDE.md template rewrite**: 494 to 127 lines, compact procedural format with full heartbeat signal reactions.
852
- - **Complete sanitization**: All hardcoded paths use `NEXO_HOME` env var. No credentials or personal data in the distributed package. Migration scripts and maintainer tooling use configurable paths.
853
-
854
- ### v1.6.0 — Nervous System + Dashboard v2 (2026-03-30)
855
- - **Nervous System**: 11 autonomous scripts (decay, deep sleep, self-audit, catchup, evolution, followup hygiene, immune, watchdog, github monitor, learning validator)
856
- - **Dashboard v2**: 6 interactive pages at localhost:6174 (Overview, Graph, Memory, Somatic, Adaptive, Sessions)
857
- - **LaunchAgent Templates**: macOS automation templates included in the package for scheduling the nervous system
858
- - **Hooks**: 7 total — SessionStart, Stop, PostToolUse, PreCompact, PostCompact
859
- - **Installer**: Now configures dashboard LaunchAgent, nervous system scripts, and all templates automatically
860
-
861
- ### v1.5.2 — Deep Sleep (2026-03-29)
862
- - **Deep Sleep**: Reads full session transcripts (not just diary) — finds uncaptured corrections, protocol violations, missed commitments
863
- - Uses Claude CLI in `--bare` mode (no hooks, no CLAUDE.md interference)
864
- - Catch-up system re-runs yesterday if the Mac was off
865
-
866
- ### v1.5.0 — Modular Core + Knowledge Graph Search (2026-03-29)
867
- - **Architecture**: `db.py` refactored into `db/` package (11 modules); `cognitive.py` into `cognitive/` package (6 modules)
868
- - **KG Boost**: Knowledge Graph connection count influences search result ranking
869
- - **HNSW Vector Index**: Optional approximate nearest neighbor acceleration (auto-activates above 10,000 memories)
870
- - **Claim Graph**: Decomposes blob memories into atomic verifiable facts with provenance and contradiction detection
871
- - **Inter-terminal Auto-inbox (D+)**: `nexo_startup` accepts `claude_session_id` for automatic inbox delivery between parallel terminals
872
- - **Tests**: 24 pytest tests across 3 suites (cognitive, knowledge graph, migrations)
873
-
874
- ### v1.4.1 — Multi-AI Code Review (2026-03-29)
875
- - **Fix**: 3 bugs found by GPT-5.4 (Codex CLI) + Gemini 2.5 (Gemini CLI) reviewing full codebase
876
- - **Security**: Memory sanitization prevents prompt injection via stored content
877
- - **Migration #13**: Normalizes legacy status values on upgrade
878
-
879
- ### v1.4.0 — The Brain Dreams (2026-03-29)
880
- - **Major**: All 9 nightly scripts migrated from Python word-overlap to CLI wrapper pattern
881
- - **Stop Hook v8**: Session-scoped tool counting, buffer fallback removed
882
- - **Guard**: Behavioral rules section surfaces most-violated rules at session start
883
-
884
- ### v1.3.0 — Evolution System (2026-03-28)
885
- - **New**: Self-improvement cycle — NEXO proposes and applies improvements weekly
886
- - Dual-mode: auto (low-risk) and review (owner approval required)
887
- - Circuit breaker, snapshot/rollback, immutable file protection
888
-
889
- ### v1.2.3 — AGPL-3.0 License (2026-03-27)
890
- - License changed from MIT to AGPL-3.0
891
-
892
- ### v1.2.1 — Stop Hook Hotfix (2026-03-27)
893
- - **Fix**: v1.2.0 deleted the flag on approve, causing infinite block loops if session didn't close immediately
894
- - **Fix**: Removed TTL on flag — it persists until SessionStart cleans it up next session
895
- - **New**: Trivial sessions (<5 meaningful tool calls) skip post-mortem entirely and approve immediately
896
- - SessionStart hook now cleans up `.postmortem-complete` flag on session start
897
-
898
- ### v1.2.0 — Blocking Stop Hook (2026-03-27)
899
- - **Fix**: Stop hook now uses `"decision": "block"` instead of `"approve"` to enforce post-mortem execution
900
- - Previous behavior: hook injected `systemMessage` but AI had already responded — instructions were never processed
901
- - New behavior: session close is blocked until AI completes self-critique, session diary, buffer entry, and followups
902
- - Flag-based mechanism (`.postmortem-complete`) allows second close attempt to succeed
903
- - Works for all NEXO users, not just specific setups
904
-
905
- ### v1.1.1 — Multi-terminal fix (2026-03-27)
906
- - **Fix**: PostCompact now reads the correct session's checkpoint in multi-terminal setups
907
- - Changelog section added to README
908
-
909
- ### v1.1.0 — Context Continuity (2026-03-27)
910
- - **Context Continuity**: PreCompact/PostCompact hooks preserve session state across compaction events
911
- - New `session_checkpoints` SQLite table + migration #12
912
- - New tools: `nexo_checkpoint_save`, `nexo_checkpoint_read`
913
- - Heartbeat automatically maintains checkpoint every interaction
914
- - Core Memory Block re-injected post-compaction with task, files, decisions, reasoning thread
915
- - 115+ total tools at the time, 20 categories
916
-
917
- ### v1.0.0 — Cognitive Cortex + Stable Release (2026-03-26)
918
- - **Cognitive Cortex**: architectural inhibitory control (ASK/PROPOSE/ACT modes)
919
- - 30 Core Rules as immutable DNA in SQLite
920
- - Designed via 3-way AI debate (Claude Opus + GPT-5.4 + Gemini 3.1 Pro)
921
- - Artifact Registry for operational facts
922
- - Full benchmark suite (LoCoMo F1: 0.588)
923
-
924
- ### v0.10.0 — Smart Context (2026-03-22)
925
- - Smart Startup: pre-loads memories from pending followups + diary
926
- - Context Packet: structured injection for subagents
927
- - Auto-Prime: keyword-triggered area learnings in heartbeat
928
- - Diary Archive: permanent subconscious memory (180d+ auto-archived)
929
-
930
- ### v0.9.0 — Cognitive Memory (2026-03-15)
931
- - Atkinson-Shiffrin memory model (STM → LTM promotion)
932
- - Semantic RAG with fastembed (BAAI/bge-base-en-v1.5, 768 dims)
933
- - Trust scoring, sentiment detection, adaptive personality modes
934
- - Ebbinghaus decay, sister detection, quarantine system
213
+ - OS and install path
214
+ - whether the runtime is packaged or sync/dev-linked
215
+ - `nexo -v`
216
+ - `nexo doctor --tier runtime --json`
935
217
 
936
218
  ## License
937
219
 
938
- AGPL-3.0 -- see [LICENSE](LICENSE)
939
-
940
- ---
941
-
942
- Created by **Francisco Cerdà Puigserver** & **NEXO** (Claude Opus) · Built by [WAzion](https://www.wazion.com)
220
+ AGPL-3.0. See [LICENSE](LICENSE).