nexo-brain 1.6.0 → 1.7.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 (145) hide show
  1. package/README.md +99 -77
  2. package/bin/nexo-brain.js +82 -3
  3. package/bin/postinstall.js +46 -0
  4. package/package.json +11 -2
  5. package/src/__pycache__/auto_close_sessions.cpython-314.pyc +0 -0
  6. package/src/__pycache__/claim_graph.cpython-314.pyc +0 -0
  7. package/src/__pycache__/evolution_cycle.cpython-314.pyc +0 -0
  8. package/src/__pycache__/hnsw_index.cpython-314.pyc +0 -0
  9. package/src/__pycache__/kg_populate.cpython-314.pyc +0 -0
  10. package/src/__pycache__/knowledge_graph.cpython-314.pyc +0 -0
  11. package/src/__pycache__/maintenance.cpython-314.pyc +0 -0
  12. package/src/__pycache__/migrate_embeddings.cpython-314.pyc +0 -0
  13. package/src/__pycache__/plugin_loader.cpython-314.pyc +0 -0
  14. package/src/__pycache__/server.cpython-314.pyc +0 -0
  15. package/src/__pycache__/storage_router.cpython-314.pyc +0 -0
  16. package/src/__pycache__/tools_coordination.cpython-314.pyc +0 -0
  17. package/src/__pycache__/tools_credentials.cpython-314.pyc +0 -0
  18. package/src/__pycache__/tools_learnings.cpython-314.pyc +0 -0
  19. package/src/__pycache__/tools_menu.cpython-314.pyc +0 -0
  20. package/src/__pycache__/tools_reminders.cpython-314.pyc +0 -0
  21. package/src/__pycache__/tools_reminders_crud.cpython-314.pyc +0 -0
  22. package/src/__pycache__/tools_sessions.cpython-314.pyc +0 -0
  23. package/src/__pycache__/tools_task_history.cpython-314.pyc +0 -0
  24. package/src/auto_close_sessions.py +3 -2
  25. package/src/cognitive/__pycache__/__init__.cpython-314.pyc +0 -0
  26. package/src/cognitive/__pycache__/_core.cpython-314.pyc +0 -0
  27. package/src/cognitive/__pycache__/_decay.cpython-314.pyc +0 -0
  28. package/src/cognitive/__pycache__/_ingest.cpython-314.pyc +0 -0
  29. package/src/cognitive/__pycache__/_memory.cpython-314.pyc +0 -0
  30. package/src/cognitive/__pycache__/_search.cpython-314.pyc +0 -0
  31. package/src/cognitive/__pycache__/_trust.cpython-314.pyc +0 -0
  32. package/src/cognitive/_core.py +1 -1
  33. package/src/cognitive/_memory.py +7 -3
  34. package/src/cognitive/_search.py +11 -10
  35. package/src/dashboard/__pycache__/__init__.cpython-314.pyc +0 -0
  36. package/src/dashboard/__pycache__/app.cpython-314.pyc +0 -0
  37. package/src/dashboard/app.py +1 -1
  38. package/src/dashboard/templates/dashboard.html +4 -4
  39. package/src/dashboard/templates/operations.html +6 -6
  40. package/src/db/__init__.py +2 -1
  41. package/src/db/__pycache__/__init__.cpython-314.pyc +0 -0
  42. package/src/db/__pycache__/_core.cpython-314.pyc +0 -0
  43. package/src/db/__pycache__/_credentials.cpython-314.pyc +0 -0
  44. package/src/db/__pycache__/_entities.cpython-314.pyc +0 -0
  45. package/src/db/__pycache__/_episodic.cpython-314.pyc +0 -0
  46. package/src/db/__pycache__/_evolution.cpython-314.pyc +0 -0
  47. package/src/db/__pycache__/_fts.cpython-314.pyc +0 -0
  48. package/src/db/__pycache__/_learnings.cpython-314.pyc +0 -0
  49. package/src/db/__pycache__/_reminders.cpython-314.pyc +0 -0
  50. package/src/db/__pycache__/_schema.cpython-314.pyc +0 -0
  51. package/src/db/__pycache__/_sessions.cpython-314.pyc +0 -0
  52. package/src/db/__pycache__/_tasks.cpython-314.pyc +0 -0
  53. package/src/db/_core.py +2 -2
  54. package/src/db/_episodic.py +71 -1
  55. package/src/db/_fts.py +12 -12
  56. package/src/db/_reminders.py +53 -14
  57. package/src/db/_schema.py +10 -0
  58. package/src/hooks/__pycache__/auto_capture.cpython-314.pyc +0 -0
  59. package/src/plugins/__pycache__/__init__.cpython-314.pyc +0 -0
  60. package/src/plugins/__pycache__/adaptive_mode.cpython-314.pyc +0 -0
  61. package/src/plugins/__pycache__/agents.cpython-314.pyc +0 -0
  62. package/src/plugins/__pycache__/artifact_registry.cpython-314.pyc +0 -0
  63. package/src/plugins/__pycache__/backup.cpython-314.pyc +0 -0
  64. package/src/plugins/__pycache__/cognitive_memory.cpython-314.pyc +0 -0
  65. package/src/plugins/__pycache__/core_rules.cpython-314.pyc +0 -0
  66. package/src/plugins/__pycache__/cortex.cpython-314.pyc +0 -0
  67. package/src/plugins/__pycache__/entities.cpython-314.pyc +0 -0
  68. package/src/plugins/__pycache__/episodic_memory.cpython-314.pyc +0 -0
  69. package/src/plugins/__pycache__/evolution.cpython-314.pyc +0 -0
  70. package/src/plugins/__pycache__/guard.cpython-314.pyc +0 -0
  71. package/src/plugins/__pycache__/knowledge_graph_tools.cpython-314.pyc +0 -0
  72. package/src/plugins/__pycache__/preferences.cpython-314.pyc +0 -0
  73. package/src/plugins/cognitive_memory.py +1 -1
  74. package/src/plugins/episodic_memory.py +29 -11
  75. package/src/plugins/evolution.py +2 -1
  76. package/src/plugins/guard.py +25 -6
  77. package/src/rules/__pycache__/__init__.cpython-314.pyc +0 -0
  78. package/src/rules/__pycache__/migrate.cpython-314.pyc +0 -0
  79. package/src/scripts/__pycache__/check-context.cpython-314.pyc +0 -0
  80. package/src/scripts/__pycache__/nexo-auto-update.cpython-314.pyc +0 -0
  81. package/src/scripts/__pycache__/nexo-catchup.cpython-314.pyc +0 -0
  82. package/src/scripts/__pycache__/nexo-cognitive-decay.cpython-314.pyc +0 -0
  83. package/src/scripts/__pycache__/nexo-daily-self-audit.cpython-314.pyc +0 -0
  84. package/src/scripts/__pycache__/nexo-evolution-run.cpython-314.pyc +0 -0
  85. package/src/scripts/__pycache__/nexo-followup-hygiene.cpython-314.pyc +0 -0
  86. package/src/scripts/__pycache__/nexo-github-monitor.cpython-314.pyc +0 -0
  87. package/src/scripts/__pycache__/nexo-immune.cpython-314.pyc +0 -0
  88. package/src/scripts/__pycache__/nexo-install.cpython-314.pyc +0 -0
  89. package/src/scripts/__pycache__/nexo-learning-housekeep.cpython-314.pyc +0 -0
  90. package/src/scripts/__pycache__/nexo-learning-validator.cpython-314.pyc +0 -0
  91. package/src/scripts/__pycache__/nexo-migrate.cpython-314.pyc +0 -0
  92. package/src/scripts/__pycache__/nexo-postmortem-consolidator.cpython-314.pyc +0 -0
  93. package/src/scripts/__pycache__/nexo-pre-commit.cpython-314.pyc +0 -0
  94. package/src/scripts/__pycache__/nexo-proactive-dashboard.cpython-314.pyc +0 -0
  95. package/src/scripts/__pycache__/nexo-reflection.cpython-314.pyc +0 -0
  96. package/src/scripts/__pycache__/nexo-runtime-preflight.cpython-314.pyc +0 -0
  97. package/src/scripts/__pycache__/nexo-send-email.cpython-314.pyc +0 -0
  98. package/src/scripts/__pycache__/nexo-send-reply.cpython-314.pyc +0 -0
  99. package/src/scripts/__pycache__/nexo-sleep.cpython-314.pyc +0 -0
  100. package/src/scripts/__pycache__/nexo-synthesis.cpython-314.pyc +0 -0
  101. package/src/scripts/__pycache__/nexo-watchdog-smoke.cpython-314.pyc +0 -0
  102. package/src/scripts/check-context.py +4 -2
  103. package/src/scripts/deep-sleep/__pycache__/analyze_session.cpython-314.pyc +0 -0
  104. package/src/scripts/deep-sleep/__pycache__/apply_findings.cpython-314.pyc +0 -0
  105. package/src/scripts/deep-sleep/__pycache__/collect_transcripts.cpython-314.pyc +0 -0
  106. package/src/scripts/deep-sleep/analyze_session.py +3 -1
  107. package/src/scripts/deep-sleep/apply_findings.py +7 -4
  108. package/src/scripts/deep-sleep/collect_transcripts.py +3 -1
  109. package/src/scripts/nexo-backup.sh +33 -0
  110. package/src/scripts/nexo-catchup.py +4 -4
  111. package/src/scripts/nexo-cognitive-decay.py +8 -5
  112. package/src/scripts/nexo-daily-self-audit.py +15 -13
  113. package/src/scripts/nexo-deep-sleep.sh +4 -3
  114. package/src/scripts/nexo-evolution-run.py +6 -3
  115. package/src/scripts/nexo-followup-hygiene.py +6 -3
  116. package/src/scripts/nexo-immune.py +5 -3
  117. package/src/scripts/nexo-inbox-hook.sh +1 -1
  118. package/src/scripts/nexo-install.py +227 -0
  119. package/src/scripts/nexo-learning-housekeep.py +241 -0
  120. package/src/scripts/nexo-learning-validator.py +2 -0
  121. package/src/scripts/nexo-migrate.py +226 -0
  122. package/src/scripts/nexo-postmortem-consolidator.py +19 -18
  123. package/src/scripts/nexo-pre-commit.py +1 -1
  124. package/src/scripts/nexo-proactive-dashboard.py +7 -5
  125. package/src/scripts/nexo-runtime-preflight.py +1 -1
  126. package/src/scripts/nexo-send-email.py +1 -1
  127. package/src/scripts/nexo-sleep.py +2 -0
  128. package/src/scripts/nexo-synthesis.py +3 -3
  129. package/src/scripts/nexo-watchdog.sh +24 -23
  130. package/src/server.py +31 -17
  131. package/src/tools_coordination.py +14 -14
  132. package/src/tools_credentials.py +11 -11
  133. package/src/tools_learnings.py +36 -27
  134. package/src/tools_menu.py +7 -6
  135. package/src/tools_reminders.py +11 -5
  136. package/src/tools_reminders_crud.py +1 -1
  137. package/src/tools_sessions.py +54 -184
  138. package/src/tools_task_history.py +7 -7
  139. package/templates/CLAUDE.md.template +92 -446
  140. package/tests/__pycache__/__init__.cpython-314.pyc +0 -0
  141. package/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc +0 -0
  142. package/tests/__pycache__/test_cognitive.cpython-314-pytest-9.0.2.pyc +0 -0
  143. package/tests/__pycache__/test_knowledge_graph.cpython-314-pytest-9.0.2.pyc +0 -0
  144. package/tests/__pycache__/test_migrations.cpython-314-pytest-9.0.2.pyc +0 -0
  145. package/tests/test_migrations.py +3 -3
package/README.md CHANGED
@@ -130,22 +130,10 @@ Like a human brain, NEXO Brain has automated processes that run while you're not
130
130
  |------|---------|---------------|
131
131
  | 03:00 | Decay + memory consolidation + merge duplicates + dreaming | Deep sleep consolidation |
132
132
  | 04:00 | Clean expired data, prune redundant memories | Synaptic pruning |
133
- | 04:30 | **Deep Sleep** — analyze full session transcripts for uncaptured corrections, protocol violations, missed commitments | REM sleep review |
134
133
  | 07:00 | Self-audit, health checks, metrics | Waking up + orientation |
135
134
  | 23:30 | Process day's events, extract patterns | Pre-sleep reflection |
136
135
  | Boot | Catch-up: run anything missed while computer was off | -- |
137
136
 
138
- #### Deep Sleep (v1.5.2)
139
-
140
- Deep Sleep reads your **complete session transcripts** (not just the diary summary) and finds what the agent missed during the day:
141
-
142
- - **Uncaptured corrections** — user corrections the agent didn't save as learnings
143
- - **Protocol violations** — guard_check skipped, trust not adjusted, change_log omitted
144
- - **Missed commitments** — things mentioned but never tracked as followups
145
- - **Quality issues** — agent declaring "done" when work wasn't complete
146
-
147
- Uses Claude CLI in `--bare` mode (no hooks, no CLAUDE.md interference). Catch-up system re-runs yesterday if the Mac was off.
148
-
149
137
  If your Mac was asleep during any scheduled process, NEXO Brain catches up in order when it wakes.
150
138
 
151
139
  ## Cognitive Cortex
@@ -210,7 +198,7 @@ This means long sessions (8+ hours) feel like one continuous conversation instea
210
198
 
211
199
  ## Cognitive Features
212
200
 
213
- NEXO Brain provides **100+ MCP tools** implementing cognitive science concepts that go beyond basic memory:
201
+ NEXO Brain provides 29 cognitive tools on top of the 78 base tools, totaling **115+ MCP tools**. These features implement cognitive science concepts that go beyond basic memory:
214
202
 
215
203
  ### Input Pipeline
216
204
 
@@ -238,13 +226,11 @@ NEXO Brain provides **100+ MCP tools** implementing cognitive science concepts t
238
226
  |---------|-------------|
239
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. |
240
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. |
241
- | **KG Boost** | Knowledge Graph connection count influences retrieval ranking. Memories linked to well-connected entities (many edges) receive a logarithmic score bonus, surfacing contextually important facts higher. |
242
- | **HNSW Vector Index** | Optional approximate nearest neighbor index (hnswlib). Activates automatically when memory count exceeds 10,000. Falls back to exact brute-force below that threshold — no configuration needed. |
243
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. |
244
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. |
245
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. |
246
232
  | **Spreading Activation** | Graph-based co-activation network. Memories retrieved together reinforce each other's connections, building an associative web that improves over time. |
247
- | **Recall Explanations** | Transparent score breakdown for every retrieval result. Shows exactly why a memory was returned: semantic similarity, recency, access frequency, KG boost, and co-activation bonuses. |
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. |
248
234
 
249
235
  ### Proactive
250
236
 
@@ -281,21 +267,62 @@ NEXO Brain was evaluated on [LoCoMo](https://github.com/snap-research/locomo) (A
281
267
 
282
268
  Full results in [`benchmarks/locomo/results/`](benchmarks/locomo/results/).
283
269
 
284
- ## Full Orchestration System (v0.7.0)
270
+ ## Nervous System (v1.6.0)
271
+
272
+ NEXO Brain doesn't just respond — it runs autonomous processes in the background, like a biological nervous system. 11 scripts 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
+ | **deep-sleep** | 04:30 daily | Reads full session transcripts, finds uncaptured corrections and protocol violations |
278
+ | **daily-self-audit** | 07:00 daily | Health checks, guard stats, trust score review, metrics |
279
+ | **catchup** | On boot | Runs any missed scheduled processes (Mac was off/asleep) |
280
+ | **evolution-run** | Weekly | Self-improvement proposals — NEXO suggests and applies enhancements |
281
+ | **followup-hygiene** | Weekly | Normalizes statuses, flags stale followups, cleans orphans |
282
+ | **immune** | 04:00 daily | Quarantine processing, memory promotion/rejection, synaptic pruning |
283
+ | **watchdog** | Every 30 min | Monitors 15+ services, LaunchAgents, and infrastructure health |
284
+ | **github-monitor** | 08:00 daily | Checks issues, PRs, and commits on public repos |
285
+ | **learning-validator** | Nightly | Validates learnings for staleness, contradictions, and duplicates |
286
+ | **cognitive-migrate** | On upgrade | Schema migrations for cognitive.db — safe, reversible evolution |
287
+
288
+ All scripts run via macOS LaunchAgents (or catch-up on Linux). If your Mac was asleep during a scheduled process, the catch-up script re-runs everything in order when it wakes.
289
+
290
+ ### LaunchAgent Templates
291
+
292
+ 13 macOS automation templates are included for scheduling the nervous system. The installer configures them automatically. On Linux, equivalent cron entries are generated.
293
+
294
+ ## Dashboard (v1.6.0)
295
+
296
+ A web interface at `localhost:6174` with 6 interactive pages for visual insight into your brain's state:
297
+
298
+ | Page | What It Shows |
299
+ |------|-------------|
300
+ | **Overview** | System health at a glance — memory counts, trust score, active sessions, recent changes |
301
+ | **Graph** | Interactive D3.js visualization of the knowledge graph (nodes, edges, clusters) |
302
+ | **Memory** | Browse and search all memory stores (STM, LTM, sensory, archived) |
303
+ | **Somatic** | Pain map per file/area — see which parts of your codebase cause the most errors |
304
+ | **Adaptive** | Personality signals, learned weights, and current mode |
305
+ | **Sessions** | Active and historical sessions with timeline and diary entries |
306
+
307
+ Built with FastAPI backend and D3.js frontend. Runs as a LaunchAgent, auto-starts with the system.
308
+
309
+ ## Full Orchestration System
285
310
 
286
311
  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.
287
312
 
288
- ### 6 Automated Hooks
313
+ ### Automated Hooks
289
314
 
290
- These fire automatically at key moments in every Claude Code session:
315
+ 8 hooks fire automatically at key moments in every Claude Code session:
291
316
 
292
317
  | Hook | When | What It Does |
293
318
  |------|------|-------------|
294
- | **SessionStart** | Session opens | Generates a briefing from SQLite: overdue reminders, today's tasks, pending followups, active sessions |
319
+ | **SessionStart** | Session opens | Generates briefing from SQLite: overdue reminders, today's tasks, pending followups, active sessions. Cleans up post-mortem flags. |
295
320
  | **Stop** | Session ends | Mandatory post-mortem: self-critique (5 questions), session buffer entry, followup creation, proactive seeds for next session |
296
- | **PostToolUse** | After each tool call | Captures meaningful mutations to the Sensory Register |
321
+ | **PostToolUse** | After each tool call | Captures meaningful mutations to the Sensory Register + inter-terminal inbox delivery |
297
322
  | **PreCompact** | Before context compression | Saves full session checkpoint to SQLite — task, files, decisions, errors, reasoning thread |
298
323
  | **PostCompact** | After context compression | Re-injects Core Memory Block so the session continues seamlessly from where it left off |
324
+ | **PreToolUse** | Before tool execution | Validates tool parameters and injects guard context for destructive operations |
325
+ | **Notification** | External events | Routes incoming notifications (GitHub, email, watchdog alerts) to the active session |
299
326
  | **Caffeinate** | Always (optional) | Keeps Mac awake for nocturnal cognitive processes |
300
327
 
301
328
  ### The Session Lifecycle
@@ -335,23 +362,25 @@ After 3+ sessions accumulate, the stop hook triggers `nexo-reflection.py`:
335
362
 
336
363
  ### Auto-Migration
337
364
 
338
- Existing users upgrading from v0.5.0:
365
+ Existing users upgrading from any previous version:
339
366
  ```bash
340
- npx nexo-brain # detects v0.5.0, migrates automatically
367
+ npx nexo-brain # detects current version, migrates automatically
341
368
  ```
342
- - Updates hooks, core files, plugins, scripts
369
+ - Updates hooks, core files, plugins, scripts, and LaunchAgent templates
370
+ - Runs `cognitive-migrate.py` for safe, reversible schema evolution
343
371
  - **Never touches your data** (memories, learnings, preferences)
344
372
  - Saves updated CLAUDE.md as reference (doesn't overwrite customizations)
345
373
 
346
- ## Knowledge Graph & Dashboard (v0.8)
374
+ For manual migration (e.g., from a custom setup):
375
+ ```bash
376
+ python3 ~/.nexo/scripts/nexo-cognitive-migrate.py
377
+ ```
378
+
379
+ ## Knowledge Graph (v0.8)
347
380
 
348
- ### Knowledge Graph
349
381
  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.
350
382
 
351
- 4 new 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).
352
-
353
- ### Web Dashboard
354
- A visual interface at `localhost:6174` with 6 pages: Overview (system health at a glance), Graph (interactive D3.js visualization of the knowledge graph), Memory (browse and search all memory stores), Somatic (pain map per file/area), Adaptive (personality signals and weights), and Sessions (active and historical sessions). Built with FastAPI backend and D3.js frontend.
383
+ 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).
355
384
 
356
385
  ### Cross-Platform Support
357
386
  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.
@@ -395,8 +424,10 @@ The installer handles everything:
395
424
  - 3 git repositories
396
425
  - Node.js project detected
397
426
  Configuring MCP server...
398
- Setting up automated processes...
399
- 6 automated processes configured.
427
+ Setting up nervous system...
428
+ 11 autonomous scripts configured.
429
+ 13 LaunchAgent templates installed.
430
+ Dashboard configured at localhost:6174.
400
431
  Caffeinate enabled.
401
432
  Generating operator instructions...
402
433
 
@@ -426,36 +457,26 @@ That's it. No need to run `claude` manually. Your operator will greet you immedi
426
457
  | Component | What | Where |
427
458
  |-----------|------|-------|
428
459
  | Cognitive engine | Python: fastembed, numpy, vector search | pip packages |
429
- | MCP server | 100+ tools for memory, cognition, learning, guard | ~/.nexo/ |
460
+ | MCP server | 111+ tools for memory, cognition, learning, guard | ~/.nexo/ |
430
461
  | Plugins | Guard, episodic memory, cognitive memory, entities, preferences | ~/.nexo/plugins/ |
431
- | Hooks (6) | SessionStart briefing, Stop post-mortem, PostToolUse capture, PreCompact checkpoint, PostCompact recovery, Caffeinate | ~/.nexo/hooks/ |
432
- | Reflection engine | Processes session buffer, extracts patterns, updates user model | ~/.nexo/scripts/ |
462
+ | Hooks (8) | SessionStart, Stop, PostToolUse, PreCompact, PostCompact, PreToolUse, Notification, Caffeinate | ~/.nexo/hooks/ |
463
+ | Nervous system | 11 autonomous scripts (decay, sleep, audit, evolution, watchdog, etc.) | ~/.nexo/scripts/ |
464
+ | Dashboard | Web UI at localhost:6174 (6 pages) | ~/.nexo/dashboard/ |
433
465
  | CLAUDE.md | Complete operator instructions (Codex, hooks, guard, trust, memory) | ~/.claude/CLAUDE.md |
434
- | LaunchAgents | Decay, sleep, audit, postmortem, catch-up | ~/Library/LaunchAgents/ |
466
+ | LaunchAgents | 13 templates for macOS automation | ~/Library/LaunchAgents/ |
435
467
  | Auto-update | Checks for new versions at boot | Built into catch-up |
436
- | Claude Code config | MCP server + 6 hooks registered | ~/.claude/settings.json |
468
+ | Claude Code config | MCP server + 8 hooks registered | ~/.claude/settings.json |
437
469
 
438
470
  ### Requirements
439
471
 
440
472
  - **macOS or Linux** (Windows via [WSL](https://learn.microsoft.com/en-us/windows/wsl/install))
441
473
  - **Node.js 18+** (for the installer)
442
- - **Claude Opus (latest version) strongly recommended.** NEXO Brain provides 100+ 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 100+ tools without hesitation.
474
+ - **Claude Opus (latest version) strongly recommended.** NEXO Brain provides 111+ 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 111+ tools without hesitation.
443
475
  - Python 3, Homebrew, and Claude Code are installed automatically if missing.
444
476
 
445
477
  ## Architecture
446
478
 
447
- ### Modular Package Structure (v1.5.0)
448
-
449
- The core is organized into two Python packages:
450
-
451
- | Package | Modules | Responsibility |
452
- |---------|---------|----------------|
453
- | `db/` | 11 modules (`_core`, `_schema`, `_sessions`, `_learnings`, `_episodic`, `_credentials`, `_entities`, `_evolution`, `_fts`, `_reminders`, `_tasks`) | All SQLite persistence: schema migrations, CRUD, FTS indexing |
454
- | `cognitive/` | 6 modules (`_core`, `_memory`, `_ingest`, `_search`, `_decay`, `_trust`) | Cognitive engine: embeddings, RAG, decay, trust scoring |
455
-
456
- The rest of the server (`server.py`, `tools_*.py`, `plugins/`) stays flat for clarity.
457
-
458
- ### 100+ MCP Tools across 20 Categories
479
+ ### 111+ MCP Tools across 20 Categories
459
480
 
460
481
  | Category | Count | Tools | Purpose |
461
482
  |----------|-------|-------|---------|
@@ -480,7 +501,6 @@ The rest of the server (`server.py`, `tools_*.py`, `plugins/`) stays flat for cl
480
501
  | Adaptive & Somatic | 4 | adaptive_weights, adaptive_override, somatic_check, somatic_stats | Learned signal weights + pain memory per file |
481
502
  | Knowledge Graph | 4 | kg_query, kg_path, kg_neighbors, kg_stats | Bi-temporal entity-relationship graph |
482
503
  | Context Continuity | 2 | checkpoint_save, checkpoint_read | Auto-compaction session preservation |
483
- | Claim Graph | — | (internal) | Atomic facts with provenance and contradiction detection |
484
504
 
485
505
  ### Plugin System
486
506
 
@@ -538,7 +558,7 @@ NEXO Brain is designed as an MCP server. Claude Code is the primary supported cl
538
558
  npx nexo-brain
539
559
  ```
540
560
 
541
- All 100+ tools are available immediately after installation. The installer configures Claude Code's `~/.claude/settings.json` automatically.
561
+ All 111+ tools are available immediately after installation. The installer configures Claude Code's `~/.claude/settings.json` automatically.
542
562
 
543
563
  ### OpenClaw
544
564
 
@@ -617,11 +637,11 @@ NEXO Brain builds on ideas from several open-source projects. We're grateful for
617
637
 
618
638
  | Project | Inspired Features |
619
639
  |---------|------------------|
620
- | Vestige | HyDE query expansion, spreading activation, prediction error gating, memory dreaming, prospective memory |
621
- | ShieldCortex | Security pipeline (4-layer memory poisoning defense) |
622
- | Bicameral | Quarantine queue (trust promotion policy for new facts) |
623
- | claude-mem | Hook auto-capture (extracting decisions and facts from conversations) |
624
- | ClawMem | Co-activation reinforcement (memories retrieved together strengthen connections) |
640
+ | [Vestige](https://github.com/pchaganti/gx-vestige) | HyDE query expansion, spreading activation, prediction error gating, memory dreaming, prospective memory |
641
+ | [ShieldCortex](https://github.com/PShieldCortex/ShieldCortex) | Security pipeline (4-layer memory poisoning defense) |
642
+ | [Bicameral](https://github.com/nicobailey/Bicameral) | Quarantine queue (trust promotion policy for new facts) |
643
+ | [claude-mem](https://github.com/nicobailey/claude-mem) | Hook auto-capture (extracting decisions and facts from conversations) |
644
+ | [ClawMem](https://github.com/nicobailey/ClawMem) | Co-activation reinforcement (memories retrieved together strengthen connections) |
625
645
 
626
646
  ## Support the Project
627
647
 
@@ -636,38 +656,40 @@ If NEXO Brain is useful to you, consider:
636
656
 
637
657
  ## Changelog
638
658
 
659
+ ### v1.6.0 — Nervous System + Dashboard v2 (2026-03-30)
660
+ - **Nervous System**: 11 autonomous scripts (decay, deep sleep, self-audit, catchup, evolution, followup hygiene, immune, watchdog, github monitor, learning validator, cognitive migrate)
661
+ - **Dashboard v2**: 6 interactive pages at localhost:6174 (Overview, Graph, Memory, Somatic, Adaptive, Sessions)
662
+ - **LaunchAgent Templates**: 13 macOS automation templates included in the package for scheduling the nervous system
663
+ - **Migration Script**: `cognitive-migrate.py` for safe, reversible schema evolution on upgrades
664
+ - **Hooks**: 8 total — added PreToolUse (parameter validation + guard injection) and Notification (external event routing)
665
+ - **Installer**: Now configures dashboard LaunchAgent, nervous system scripts, and all 13 templates automatically
666
+
667
+ ### v1.5.2 — Deep Sleep (2026-03-29)
668
+ - **Deep Sleep**: Reads full session transcripts (not just diary) — finds uncaptured corrections, protocol violations, missed commitments
669
+ - Uses Claude CLI in `--bare` mode (no hooks, no CLAUDE.md interference)
670
+ - Catch-up system re-runs yesterday if the Mac was off
671
+
639
672
  ### v1.5.0 — Modular Core + Knowledge Graph Search (2026-03-29)
640
- - **Architecture**: `db.py` refactored into `db/` package (11 modules: core, schema, sessions, learnings, episodic, credentials, entities, evolution, fts, reminders, tasks)
641
- - **Architecture**: `cognitive.py` refactored into `cognitive/` package (6 modules: core, memory, ingest, search, decay, trust)
642
- - **KG Boost**: Knowledge Graph connection count now influences search result ranking — well-connected entities surface higher in retrieval
643
- - **HNSW Vector Index**: Optional approximate nearest neighbor acceleration (activates automatically above 10,000 memories, falls back to brute-force otherwise)
644
- - **Claim Graph**: Decomposes blob memories into atomic verifiable facts with provenance, confidence scores, and contradiction detection
645
- - **Inter-terminal Auto-inbox (D+)**: `nexo_startup` now accepts `claude_session_id` (Claude Code session UUID) — enables automatic inbox delivery between parallel terminals via PostToolUse hook + migration v13
673
+ - **Architecture**: `db.py` refactored into `db/` package (11 modules); `cognitive.py` into `cognitive/` package (6 modules)
674
+ - **KG Boost**: Knowledge Graph connection count influences search result ranking
675
+ - **HNSW Vector Index**: Optional approximate nearest neighbor acceleration (auto-activates above 10,000 memories)
676
+ - **Claim Graph**: Decomposes blob memories into atomic verifiable facts with provenance and contradiction detection
677
+ - **Inter-terminal Auto-inbox (D+)**: `nexo_startup` accepts `claude_session_id` for automatic inbox delivery between parallel terminals
646
678
  - **Tests**: 24 pytest tests across 3 suites (cognitive, knowledge graph, migrations)
647
679
 
648
680
  ### v1.4.1 — Multi-AI Code Review (2026-03-29)
649
681
  - **Fix**: 3 bugs found by GPT-5.4 (Codex CLI) + Gemini 2.5 (Gemini CLI) reviewing full codebase
650
- - `session_diaries` → `session_diary` table name (smart startup silently failed)
651
- - Quarantine contradiction logic distinguished confirmation from opposition
652
- - Knowledge Graph timezone import crash
653
682
  - **Security**: Memory sanitization prevents prompt injection via stored content
654
- - **Migration #13**: Normalizes legacy status values (PENDIENTE→PENDING) on upgrade
683
+ - **Migration #13**: Normalizes legacy status values on upgrade
655
684
 
656
685
  ### v1.4.0 — The Brain Dreams (2026-03-29)
657
686
  - **Major**: All 9 nightly scripts migrated from Python word-overlap to CLI wrapper pattern
658
- - Postmortem consolidator: opus understands patterns by meaning, not word overlap
659
- - Sleep system: detects real duplicates via semantic understanding
660
- - Daily synthesis: opus prioritizes what matters for tomorrow
661
- - Self-audit: interprets findings for root cause analysis
662
- - Evolution: prompt reduced 95% (45K → 2.2K chars) — CLI investigates using tools
663
- - **Stop Hook v8**: Session-scoped tool counting (not day-wide), buffer fallback removed
687
+ - **Stop Hook v8**: Session-scoped tool counting, buffer fallback removed
664
688
  - **Guard**: Behavioral rules section surfaces most-violated rules at session start
665
- - **Followup hygiene**: Weekly cleanup script normalizes statuses, flags stale items
666
- - 8 missing core scripts + 1 plugin added to repository
667
689
 
668
690
  ### v1.3.0 — Evolution System (2026-03-28)
669
691
  - **New**: Self-improvement cycle — NEXO proposes and applies improvements weekly
670
- - Dual-mode: auto (low-risk changes) and review (owner approval required)
692
+ - Dual-mode: auto (low-risk) and review (owner approval required)
671
693
  - Circuit breaker, snapshot/rollback, immutable file protection
672
694
 
673
695
  ### v1.2.3 — AGPL-3.0 License (2026-03-27)
@@ -696,7 +718,7 @@ If NEXO Brain is useful to you, consider:
696
718
  - New tools: `nexo_checkpoint_save`, `nexo_checkpoint_read`
697
719
  - Heartbeat automatically maintains checkpoint every interaction
698
720
  - Core Memory Block re-injected post-compaction with task, files, decisions, reasoning thread
699
- - 115+ total tools, 20 categories, 6 hooks
721
+ - 115+ total tools, 20 categories
700
722
 
701
723
  ### v1.0.0 — Cognitive Cortex + Stable Release (2026-03-26)
702
724
  - **Cognitive Cortex**: architectural inhibitory control (ASK/PROPOSE/ACT modes)
package/bin/nexo-brain.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * 3. Installs Python dependencies (fastembed, numpy, mcp)
11
11
  * 4. Creates ~/.nexo/ with DB, personality, and config
12
12
  * 5. Configures Claude Code MCP settings
13
- * 6. Creates LaunchAgents for macOS automated processes
13
+ * 6. Creates LaunchAgents (macOS) / systemd timers (Linux) / crontab (fallback) for automated processes
14
14
  * 7. Generates CLAUDE.md with the operator's instructions
15
15
  */
16
16
 
@@ -1388,9 +1388,88 @@ ${doScan ? `- Stack: ${Object.keys(profileData.code.languages || {}).slice(0, 5)
1388
1388
  } catch {}
1389
1389
  log("Caffeinate enabled — Mac will stay awake for cognitive processes.");
1390
1390
  }
1391
+ } else if (platform === "linux") {
1392
+ // Linux: use systemd user timers (preferred) or crontab as fallback
1393
+ const systemdDir = path.join(require("os").homedir(), ".config", "systemd", "user");
1394
+ const hasSystemd = run("which systemctl") && run("systemctl --user status 2>/dev/null");
1395
+
1396
+ if (hasSystemd) {
1397
+ fs.mkdirSync(systemdDir, { recursive: true });
1398
+
1399
+ const linuxAgents = [
1400
+ { name: "cognitive-decay", script: "nexo-cognitive-decay.py", calendar: "*-*-* 03:00:00" },
1401
+ { name: "postmortem", script: "nexo-postmortem-consolidator.py", calendar: "*-*-* 23:30:00" },
1402
+ { name: "sleep", script: "nexo-sleep.py", calendar: "*-*-* 04:00:00" },
1403
+ { name: "self-audit", script: "nexo-daily-self-audit.py", calendar: "*-*-* 07:00:00" },
1404
+ ];
1405
+
1406
+ linuxAgents.forEach((agent) => {
1407
+ const serviceName = `nexo-${agent.name}`;
1408
+ const serviceFile = path.join(systemdDir, `${serviceName}.service`);
1409
+ const timerFile = path.join(systemdDir, `${serviceName}.timer`);
1410
+
1411
+ const service = `[Unit]
1412
+ Description=NEXO Brain — ${agent.name}
1413
+
1414
+ [Service]
1415
+ Type=oneshot
1416
+ ExecStart=${venvPython} ${path.join(NEXO_HOME, "scripts", agent.script)}
1417
+ Environment=HOME=${require("os").homedir()}
1418
+ Environment=NEXO_HOME=${NEXO_HOME}
1419
+ StandardOutput=append:${path.join(NEXO_HOME, "logs", `${agent.name}-stdout.log`)}
1420
+ StandardError=append:${path.join(NEXO_HOME, "logs", `${agent.name}-stderr.log`)}
1421
+ `;
1422
+
1423
+ const timer = `[Unit]
1424
+ Description=NEXO Brain — ${agent.name} timer
1425
+
1426
+ [Timer]
1427
+ OnCalendar=${agent.calendar}
1428
+ Persistent=true
1429
+
1430
+ [Install]
1431
+ WantedBy=timers.target
1432
+ `;
1433
+
1434
+ fs.writeFileSync(serviceFile, service);
1435
+ fs.writeFileSync(timerFile, timer);
1436
+ try {
1437
+ execSync(`systemctl --user enable --now ${serviceName}.timer 2>/dev/null`, { stdio: "pipe" });
1438
+ } catch {}
1439
+ });
1440
+
1441
+ // Catchup runs at startup via MCP — no timer needed
1442
+ log(`${linuxAgents.length} systemd user timers configured.`);
1443
+ } else {
1444
+ // Fallback: crontab
1445
+ log("systemd not available, configuring crontab...");
1446
+ const cronLines = [
1447
+ `0 3 * * * ${venvPython} ${path.join(NEXO_HOME, "scripts", "nexo-cognitive-decay.py")} >> ${path.join(NEXO_HOME, "logs", "cognitive-decay-stdout.log")} 2>&1`,
1448
+ `30 23 * * * ${venvPython} ${path.join(NEXO_HOME, "scripts", "nexo-postmortem-consolidator.py")} >> ${path.join(NEXO_HOME, "logs", "postmortem-stdout.log")} 2>&1`,
1449
+ `0 4 * * * ${venvPython} ${path.join(NEXO_HOME, "scripts", "nexo-sleep.py")} >> ${path.join(NEXO_HOME, "logs", "sleep-stdout.log")} 2>&1`,
1450
+ `0 7 * * * ${venvPython} ${path.join(NEXO_HOME, "scripts", "nexo-daily-self-audit.py")} >> ${path.join(NEXO_HOME, "logs", "self-audit-stdout.log")} 2>&1`,
1451
+ ];
1452
+
1453
+ try {
1454
+ const existingCron = run("crontab -l 2>/dev/null") || "";
1455
+ const nexoCronMarker = "# NEXO Brain automated processes";
1456
+ if (!existingCron.includes(nexoCronMarker)) {
1457
+ const newCron = existingCron + "\n" + nexoCronMarker + "\n" + cronLines.join("\n") + "\n";
1458
+ const tmpCron = path.join(NEXO_HOME, ".crontab-tmp");
1459
+ fs.writeFileSync(tmpCron, newCron);
1460
+ execSync(`crontab ${tmpCron}`, { stdio: "pipe" });
1461
+ fs.unlinkSync(tmpCron);
1462
+ log(`${cronLines.length} cron jobs configured.`);
1463
+ } else {
1464
+ log("NEXO cron jobs already configured.");
1465
+ }
1466
+ } catch (e) {
1467
+ log(`Could not configure crontab: ${e.message}`);
1468
+ log("Background tasks will run via catch-up on startup.");
1469
+ }
1470
+ }
1391
1471
  } else {
1392
- log("Non-macOS platform: background tasks will run via catch-up on startup.");
1393
- log(" No OS scheduler configured — NEXO runs maintenance when MCP starts.");
1472
+ log("Unsupported platform for background tasks. Maintenance runs on MCP startup.");
1394
1473
  }
1395
1474
 
1396
1475
  // Step 8: Create shell alias so user can just type the operator's name
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall — Runs automatically after npm install/update.
4
+ *
5
+ * - If NEXO is already installed (~/.nexo/version.json exists): auto-migrate
6
+ * - If fresh install: print setup instructions only
7
+ */
8
+
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+
12
+ const NEXO_HOME = path.join(require("os").homedir(), ".nexo");
13
+ const VERSION_FILE = path.join(NEXO_HOME, "version.json");
14
+
15
+ if (fs.existsSync(VERSION_FILE)) {
16
+ // Existing installation — run auto-migration silently
17
+ try {
18
+ const installed = JSON.parse(fs.readFileSync(VERSION_FILE, "utf8"));
19
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
20
+
21
+ if (installed.version === pkg.version) {
22
+ // Same version, nothing to do
23
+ process.exit(0);
24
+ }
25
+
26
+ console.log(`\n NEXO Brain: upgrading v${installed.version} → v${pkg.version}...`);
27
+
28
+ // Run the main installer in --yes mode (non-interactive)
29
+ // It will detect the existing version and do migration only
30
+ const { execSync } = require("child_process");
31
+ execSync(`node ${path.join(__dirname, "nexo-brain.js")} --yes`, {
32
+ stdio: "inherit",
33
+ env: { ...process.env, NEXO_POSTINSTALL: "1" }
34
+ });
35
+ } catch (e) {
36
+ console.error(` NEXO Brain: migration warning — ${e.message}`);
37
+ console.log(" Run 'nexo-brain' manually to complete setup.");
38
+ }
39
+ } else {
40
+ // Fresh install — just show instructions
41
+ console.log("\n ╔════════════════════════════════════════════╗");
42
+ console.log(" ║ NEXO Brain installed successfully! ║");
43
+ console.log(" ║ ║");
44
+ console.log(" ║ Run 'nexo-brain' to complete setup. ║");
45
+ console.log(" ╚════════════════════════════════════════════╝\n");
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexo-brain",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "mcpName": "io.github.wazionapps/nexo",
5
5
  "description": "NEXO — Cognitive co-operator for Claude Code. Atkinson-Shiffrin memory, semantic RAG, knowledge graph, HNSW vector indexing, trust scoring, and metacognitive error prevention.",
6
6
  "bin": {
@@ -17,6 +17,11 @@
17
17
  "knowledge-graph",
18
18
  "hnsw",
19
19
  "claim-graph",
20
+ "dashboard",
21
+ "launchagent",
22
+ "autonomous-agent",
23
+ "somatic-markers",
24
+ "nervous-system",
20
25
  "openclaw",
21
26
  "openclaw-plugin"
22
27
  ],
@@ -26,11 +31,15 @@
26
31
  "type": "git",
27
32
  "url": "git+https://github.com/wazionapps/nexo.git"
28
33
  },
34
+ "scripts": {
35
+ "postinstall": "node bin/postinstall.js 2>/dev/null || true"
36
+ },
29
37
  "engines": {
30
38
  "node": ">=18"
31
39
  },
32
40
  "files": [
33
- "bin/",
41
+ "bin/nexo-brain.js",
42
+ "bin/postinstall.js",
34
43
  "src/",
35
44
  "templates/",
36
45
  "scripts/",
@@ -21,8 +21,9 @@ from db import (
21
21
  SESSION_STALE_SECONDS,
22
22
  )
23
23
 
24
- LOG_DIR = os.path.expanduser("~/claude/operations/tool-logs")
25
- AUTO_CLOSE_LOG = os.path.expanduser("~/claude/coordination/auto-close.log")
24
+ NEXO_HOME = os.environ.get("NEXO_HOME", os.path.expanduser("~/.nexo"))
25
+ LOG_DIR = os.path.join(NEXO_HOME, "operations", "tool-logs")
26
+ AUTO_CLOSE_LOG = os.path.join(NEXO_HOME, "coordination", "auto-close.log")
26
27
 
27
28
 
28
29
  def get_tool_log_summary(sid: str) -> str:
@@ -11,7 +11,7 @@ from datetime import datetime, timedelta
11
11
  from pathlib import Path
12
12
  from typing import Optional
13
13
 
14
- COGNITIVE_DB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cognitive.db")
14
+ COGNITIVE_DB = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "cognitive.db")
15
15
  EMBEDDING_DIM = 768
16
16
  LAMBDA_STM = 0.1 # half-life ~7 days
17
17
  LAMBDA_LTM = 0.012 # half-life ~60 days
@@ -398,18 +398,20 @@ def get_stats() -> dict:
398
398
  """Return statistics about the cognitive memory system."""
399
399
  db = _get_db()
400
400
 
401
- stm_active = db.execute("SELECT COUNT(*) FROM stm_memories WHERE promoted_to_ltm = 0").fetchone()[0]
401
+ stm_active = db.execute("SELECT COUNT(*) FROM stm_memories WHERE lifecycle_state = 'active' AND promoted_to_ltm = 0").fetchone()[0]
402
+ stm_promoted = db.execute("SELECT COUNT(*) FROM stm_memories WHERE promoted_to_ltm = 1").fetchone()[0]
403
+ stm_total = db.execute("SELECT COUNT(*) FROM stm_memories WHERE lifecycle_state = 'active'").fetchone()[0]
402
404
  ltm_active = db.execute("SELECT COUNT(*) FROM ltm_memories WHERE is_dormant = 0").fetchone()[0]
403
405
  ltm_dormant = db.execute("SELECT COUNT(*) FROM ltm_memories WHERE is_dormant = 1").fetchone()[0]
404
406
 
405
- avg_stm = db.execute("SELECT AVG(strength) FROM stm_memories WHERE promoted_to_ltm = 0").fetchone()[0] or 0.0
407
+ avg_stm = db.execute("SELECT AVG(strength) FROM stm_memories WHERE lifecycle_state = 'active' AND promoted_to_ltm = 0").fetchone()[0] or 0.0
406
408
  avg_ltm = db.execute("SELECT AVG(strength) FROM ltm_memories WHERE is_dormant = 0").fetchone()[0] or 0.0
407
409
 
408
410
  total_retrievals = db.execute("SELECT COUNT(*) FROM retrieval_log").fetchone()[0]
409
411
  avg_retrieval_score = db.execute("SELECT AVG(top_score) FROM retrieval_log").fetchone()[0] or 0.0
410
412
 
411
413
  top_domains_stm = db.execute(
412
- "SELECT domain, COUNT(*) as cnt FROM stm_memories WHERE promoted_to_ltm = 0 AND domain != '' GROUP BY domain ORDER BY cnt DESC LIMIT 5"
414
+ "SELECT domain, COUNT(*) as cnt FROM stm_memories WHERE lifecycle_state = 'active' AND promoted_to_ltm = 0 AND domain != '' GROUP BY domain ORDER BY cnt DESC LIMIT 5"
413
415
  ).fetchall()
414
416
  top_domains_ltm = db.execute(
415
417
  "SELECT domain, COUNT(*) as cnt FROM ltm_memories WHERE is_dormant = 0 AND domain != '' GROUP BY domain ORDER BY cnt DESC LIMIT 5"
@@ -420,6 +422,8 @@ def get_stats() -> dict:
420
422
 
421
423
  return {
422
424
  "stm_active": stm_active,
425
+ "stm_promoted": stm_promoted,
426
+ "stm_total": stm_total,
423
427
  "ltm_active": ltm_active,
424
428
  "ltm_dormant": ltm_dormant,
425
429
  "avg_stm_strength": round(avg_stm, 3),